How to Run Cypress Test Files in a Specific Order

How to Run Cypress Test Files in a Specific Order

21 May 2024 Stephan Petzl Leave a comment Tech-Help

When running multiple test files in Cypress, the default behavior is to execute them in alphabetical order. However, there are scenarios where you might want to customize the order of execution. This guide will help you achieve that by providing several methods to run Cypress test files in your desired order.

Using specPattern Configuration

One efficient way to control the order of test execution is by using the specPattern configuration property in your cypress.json or cypress.config.ts file. This method allows you to list your spec files in the exact order you want them to run.

Example Configuration

Below is an example of how to set the spec file run order in cypress.json:

  "baseUrl": "http://localhost:5000",
  "specPattern": [

This configuration ensures that the spec files are executed in the order they are listed.

Prefixing File Names

If you prefer a simpler approach, you can prefix your test file names with numbers to enforce the desired order. For example:


Cypress will run these files in alphabetical order, which now corresponds to the numerical order you have set.

Advanced Configuration

For more complex scenarios, such as prioritizing test execution based on different criteria, you can use multiple configuration files. Here is an example of how to set up different priority levels:

  "integrationFolder": "cypress/integration",
  "testFiles": [

You can load these configurations using the cypress --configFile argument to run tests based on their priority.

Best Practices

While running tests in a specific order can be useful, it’s essential to ensure that each test can run independently. Tests should not depend on the state set by previous tests. This independence allows for parallel execution and better maintainability.

Integrating with Repeato for Automated Testing

Managing and executing tests efficiently is crucial for maintaining the quality of your applications. Repeato, a no-code test automation tool for iOS and Android, can help streamline this process. Repeato allows you to create, run, and maintain automated tests for your apps quickly and efficiently. With its computer vision and AI-based approach, Repeato ensures accurate and reliable test execution.

Repeato provides an intuitive test recorder for beginners and a scripting interface for advanced testers, making it versatile for various testing needs. Additionally, Repeato supports testing websites inside an Android emulator or device, with explicit web testing support coming later this summer.

For more details on how Repeato can enhance your testing workflow, visit our blog or check out our documentation.

Like this article? there’s more where that came from!