Cypress - How can I run test files in order

I have a particular case where I launch multiple instances of an app, rather than using fixtures or test data, I simply integrate user feedback as Cypress tests from login on forwards.

In any case, I used the testFiles config in cypress.json to set the spec file run order:

{
  "baseUrl": "http://localhost:5000",
  "testFiles": [
    "login/*.js",
    "leads/new-lead.spec.js",
    "leads/leads-list.spec.js",
    "leads/lead-detail.spec.js",
    "leads/lead-modify.spec.js",
    //...
  ]
}

No file numbering needed :D


The easiest solution is most likely to add a prefix to all your test files, such as:

  • 01-chat_app_connect.spec.js
  • 02-chat_connect.spec.js

etc.

Cypress is going to take those files in alphabetical order, which you can "trick" into your wanted behavior by using a number as a prefix.