'How to run tests outside of integration folder in Cypress
I have project B linked to project A with npm link
and am trying to run tests from B in A. Project A builds the entire front end and could use other modules than just B and so I want to be able have the test runner use A and its tests but also use tests from the linked project (assuming the linked projects all use similar Cypress directory structures). I first tried this by setting the testFiles
attribute in the config to an array like [/path/to/ProjectATestingRoot/integration/**/*.*", "/path/to/ProjectBTestingRoot/integration/**/*.*"]
and running Cypress with integrationFolder
to be from project A. While I'm able to see all my tests when I open Cypress, only project A's tests can be run. When I run project B's they get stuck when the browser loads the test and displays the "Your tests are loading..." screen for eternity.
Is there any way that I could run tests from outside the set integration folder? I thought I could write a little plugin to copy the testing files over but that seems more laborious than needed.
Solution 1:[1]
Solution 2:[2]
"testFiles": "**/*.{feature,spec.tsx}", "integrationFolder": ".", "ignoreTestFiles": "**/node_modules/**/*{feature,spec.js}"
Add this to your cypress.json
. It adds all the files with .spec.tsx
ignoring the ones inside the node_module.
Solution 3:[3]
There are 2 options
1 You can specify integrationFolder
in the cypress.json
{
//....
"integrationFolder": "cypress/tests"
// or
// "integrationFolder": "tests"
}
More information https://docs.cypress.io/guides/references/configuration#Folders-Files
2 You can specify integration folder for each test run
npx cypress --config integrationFolder=cypress/tests
npx cypress --config integrationFolder=tests
More information https://github.com/cypress-io/cypress/issues/2256#issuecomment-544408366
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 | Rosen Mihaylov |
Solution 2 | David R |
Solution 3 |