PeaceT
PeaceT

Reputation: 63

No files found in cypress test runner

This weird thing happen where I got a ' No files found in cypress test runner' error message all of a sudden. enter image description here

However the files are in the folder, I have moved it to a new folder and tried running it but I still got the error message. Please any thoughts or idea as to why this happened? enter image description here

I also tried running it in headless mode but I got the same error message. enter image description here

Thank you. @Nanker Phelge please any thoughts as how to fix this issue. Thanks

Upvotes: 1

Views: 7539

Answers (3)

shreyas
shreyas

Reputation: 57

I also faced the same issue, but after renaming the test file from "testfilename.js" to "testfilename.cy.js", then the tool recognized the test file. enter image description here

Upvotes: 0

user15239601
user15239601

Reputation:

By default, if you have not configured anything different, Cypress looks in all subfolders of the integration folder.

Please see Configuration

Folders / Files

Option Default
testFiles **/*.*

where ** is part of a glob pattern that means 'look in all the sub folders - for all file types'.

If you have something else configured, that might be causing it, but if there is no entry then cypress.json is not the cause.

Else, if you have *.spec.js or */*.js these will exclude your files (because there's no .spec.js extension and a single * will exclude subfolders.

Speaking of excluding, if there is an ignoreTestFiles configuration entry (in cypress.json), that may be causing the problem.


I would also like to point out the PageObjects folder may be considered as tests and cause you more errors.

A common pattern is to name all files that have tests with the .spec.js extension e.g GTProject1.spec.js.

In the cypress.json file, set

testFiles: "**/*.spec.js"

which means look in the /cypress/integration folder and any sub-folders for files with the extension .spec.js. It will ignore you PageObject files which just have the .js extension.

Then you can rearrange the folders later and still see all the tests.

Upvotes: 6

Alapan Das
Alapan Das

Reputation: 18618

You can execute tests like this -

npx cypress run --spec=cypress/integration/GTProjects/*

Or, you can add all your tests as an array under testFiles in your cypress.json file, and in that case you can directly use npx cypress run.

"testFiles": [
  "GTProjects/GTProject1.js",
  "GTProjects/GTProject2.js",
  "GTProjects/GTProject3.js",
  "GTProjects/GTProject4.js",
  "GTProjects/GTProject5.js",
  "GTProjects/GTProject6.js",
  "GTProjects/GTProject7.js",
  "GTProjects/GTProject8.js",
  "GTProjects/GTProject9.js"
]

Or, You can provide integrationFolder path in your cypress.json and in that case, also you can execute the tests using npx cypress run

"integrationFolder": "cypress/integration/GTProjects"

Upvotes: 0

Related Questions