'How to make Cypress use test files located outside of default integration folder?
I am trying to keep my **.spec.js files for testing next to the actual files that need to be tested like such:
.
├── product
| ├── product.js
| ├── product.spec.js
├── user
| ├── user.js
| ├── user.spec.js
The above *.spec.js files don't appear in the cypress test runner window and I can't find out how to add them.
It only the displays the contents of the ./cypress/integration folder which contains the example tests included by cypress.
I know you can change the configuration of Cypress to look at a different default folder (other than cypress/integrations) for tests but my *.spec.js files are spread across several different folders.
Is is possible to have cypress test files in different folders and appear in the GUI test runner?
Solution 1:[1]
In the configuration file cypress.json, add (for example)
{
...
"integrationFolder": ".",
"testFiles": ["cypress/integration/**/*.spec.js", "src/**/*.test.js"]
}
integrationFolder: "." designates the project root to start scan for test files.
But be careful, can pick up tests in node_modules, so use an array of locations in the testFiles option to indicate folders that have valid tests for your project.
Solution 2:[2]
Why not delete the example tests/folder inside the integration folder and put yours instead?
integration
??? product
| ??? product.js
| ??? product.spec.js
??? user
| ??? user.js
| ??? user.spec.js
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fody |
| Solution 2 | aldrine00 |
