Home > OS >  Run only spec files in cypress
Run only spec files in cypress

Time:12-04

I have my folder structure like this within integration folder, I have Page Object folder, where I have two js files i.e. LoginPage.js and SignUpPage.js and outside of that PageObject folder, I have spec files i.e. LoginTestCases.spec.js and SignUpTestCases.spec.js

While running :

npx cypress open

It ran all js files present within Integration folder, but I want to run spec files only and i want to see only those files on my TestRunner as well.

I know that we do some little change in cypress.json file, but Don't remember at all. Can anyone help me out, here?

CodePudding user response:

In your cypress.json file, add the list of spec files you want to run under testFiles array, something like this. And this will only execute the spec files that you have mentioned and also in the order you have mentioned.

If your spec files are inside integration folder

"testFiles": [
  "LoginTestCases.spec.js",
  "SignUpTestCases.spec.js"
]

If the spec files are somewhere else, then you have to give the absolute path.

"testFiles": [
  "path to TC/LoginTestCases.spec.js",
  "path to TC/SignUpTestCases.spec.js"
]

In case you want to just get only the .spec.js files and you have a lot of files, you can use the wild card using:

"testFiles": ["*.spec.js"]
  • Related