Turn your manual testers into automation experts! Request a DemoStart testRigor Free

“No tests found” in Cypress: Troubleshooting Empty Test Files

The “No tests found” error in Cypress is a common issue developers encounter while running their Cypress test suite. This error message indicates that Cypress couldn’t find any test files to execute, which can be frustrating, especially when you’ve spent time writing tests. In this guide, we’ll explore why this error occurs and provide detailed solutions to help you resolve it.

Understanding the “No tests found” Error

Before we start fixing things, let’s first figure out what might be causing the issue:

  • Incorrect File Path: Cypress may not find your test files if the file path specified in your cypress.json configuration or during the test run command is wrong. Double-check the file path to ensure it’s accurate.
  • Misconfigured Cypress Configuration: If something’s off in your setup, it might not pick up your test files. So, give your cypress.json file a once-over to catch any mistakes or wonky settings.
  • Empty Test Files: If your test files do not contain any actual test cases, Cypress won’t find any tests to run, resulting in the “No tests found” error.
  • Incorrect Test File Naming: Cypress follows a specific naming convention to identify test files. Ensure your test files are named with .spec.js or .spec.ts at the end. For example, my-test.spec.js.
  • Test File Location: Ensure your test files are in the directory specified in your Cypress configuration. Cypress looks for test files in the cypress/integration directory by default.
  • File Encoding Issues: Sometimes, file encoding problems can prevent Cypress from recognizing your test files. Ensure that your test files are encoded in UTF-8 format.
  • Plugins or Dependencies: Conflicts with Cypress plugins or dependencies can sometimes lead to this error. Try disabling or updating any problematic plugins.

Alright, we’ve pinned down some possible reasons for the hiccup. Let’s chat about how to sort it out:

Troubleshooting and Resolving the “No tests found” Error

  • Verify Test File Existence and Location: Double-check the existence and location of your test files. They should be in the cypress/integration directory by default. Ensure the file names have the .spec.js or .spec.ts extension.
  • Correct File Path Configuration: Review your cypress.json configuration file and ensure that the integrationFolder property points to the valid directory containing your test files. For example:
    {
    "integrationFolder": "path/to/your/tests"
    }
  • Ensure Test Files Have Valid Tests: Open your test files and verify that they contain valid Cypress test codes. A basic test using it should look like this:
    it ('should perform some test', () => {
      // Your test code here
    });
  • Check File Encoding: Confirm that your test files are encoded in UTF-8 format. Encoding issues can cause problems with test discovery.
  • Clear Cached Files: Sometimes, cached files can lead to this error. Clear your browser cache, Cypress cache, and any temporary files. You can do this using commands like:
    npx cypress cache clear
  • Reinstall Cypress Dependencies: If you suspect issues with Cypress dependencies, you can reinstall them by deleting your node_modules folder and running npm install or yarn install again.
  • Check Cypress Version: Ensure you are using a compatible version of Cypress. In some cases, updating to the latest version can resolve compatibility issues.
  • Disable or Update Plugins: If you have Cypress plugins installed, try disabling them temporarily to see if they are causing the issue. If so, update or replace the problematic plugins with more up-to-date versions.
  • Terminal/IDE Issues: Terminal or IDE-related issues can sometimes interfere with test discovery. Try running Cypress from a different terminal or IDE to see if that resolves the problem.
  • Debugging: Use Cypress’s built-in debugging tools to help diagnose the issue. You can add debugger statements in your test files and run Cypress in debug mode. This can help identify where the test discovery process is failing.
  • Cypress Folder Structure: Ensure your project’s folder structure adheres to Cypress’s default conventions. If you’ve customized your project structure, ensure Cypress can still locate your test files.
  • Review Configuration: Cross-check your cypress.json setup to make sure there are no mistakes or wrong settings. Usually, it should be in the correct JSON format.
  • Check CI/CD Environments: If you’re encountering this issue in a CI/CD environment, ensure the necessary files and configurations are correctly set up there. Pay attention to the differences between your local and CI/CD environments.
  • Consult Cypress Documentation and Community: If all else fails, consult the official Cypress documentation and community forums. Other users may have encountered similar issues and found solutions.

Automation: Making it Smarter

The use of Cypress is scarce, and it is not a new-generation automation tool. Moreover, it is considered dead among modern web frameworks. Intelligent automation tools, like testRigor, utilize AI-powered algorithms to prevent timeout errors, and its test scripts are ultra-stable. Let’s see a few helpful features of testRigor:

  • Automatic Test Generation – Utilizing generative AI, testRigor facilitates the automatic creation of test scripts. Provide the test case title or description; test steps are generated automatically in seconds.
  • Cloud-hosted: It is a cloud-based tool that gets rid of all the setup headaches. Just grab a license, log in, and you are off to the races – no fuss, just results. A real time-saver!
  • Easy Test Script Creation/Maintenance – testRigor allows the crafting of test cases in plain English, eliminating the need for programming languages. This approach empowers anyone to create or modify test cases, simplifying the script debugging. Also, whenever the application UI or element attributes are changed, testRigor automatically accommodates the changes in the test scripts through its groundbreaking self-healing capabilities. This feature removes the huge test maintenance burden of the tester’s shoulders.
  • Cross-browser and Cross-platform Support – testRigor effortlessly manages the testing process across different browser versions and platforms.
  • Custom Element Locators – testRigor is independent of unreliable XPaths or CSS selectors. Instead, it employs a unique method of identifying elements powered by its AI algorithms, called testRigor locators. Users can specify the element’s name or its position, such as:
    click "Cart"
    click on button "Delete" below "Section Name" to the right of "label"

Discover how testRigor can serve as an excellent substitute for Cypress.

Summing Up

It’s quite vexing when a testing tool can not locate the test files, an issue that ideally shouldn’t exist. Always consider choosing an automation testing tool that is up-to-date and in line with current technological advancements. In this context, testRigor stands out due to its ability to self-heal test scripts and its user-friendly, AI-powered, simple, codeless test script creation feature. 

To explore its capabilities, you can register for a free trial. here.

Join the next wave of functional testing now.
A testRigor specialist will walk you through our platform with a custom demo.
Related Articles

SAP Concur Testing

Concur Technologies, now SAP Concur, is an American software-as-a-service (SaaS) company providing travel and expense management ...

Authorize.net Testing

You need a payment gateway in several scenarios, especially when you are running a business that requires secure, efficient, and ...

KYC Portal CLM Testing

KYC Portal CLM is an award-winning Client Lifecycle Management (CLM) platform designed to streamline and automate the Know Your ...