I use cypress for component and for e2e tests. Both tests are in the same folder, .test.e2e.js for e2e tests and .test.ct.ts for component tests. When I run component tests I only want to test the .test.ct.ts files and to test the e2e tests only the .test.e2e.ts files. It works for component tests, cypress tests only the .test.ct.ts files but when I run the e2e test cypress tests the .test.ct.ts, too and this leads to failed tests.
{
"baseUrl": "http://localhost:8080/",
"fixturesFolder": "test/cypress/fixtures",
"integrationFolder": "test/cypress/tests/",
"pluginsFile": "test/cypress/plugins/index.ts",
"screenshotsFolder": "test/cypress/screenshots",
"supportFile": "test/cypress/support/index.ts",
"videosFolder": "test/cypress/videos",
"video": false,
"component": {
"componentFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.ct.ts","**/*.test.ct.js"],
"supportFile": "test/cypress/support/component.ts"
}
}
This is my cypress config file. For component testing I can configure folder and files, I tried this with integration but it didn't work. I'm using cypress 9.7.0
And this is the config I tried
{
"baseUrl": "http://localhost:8080/",
"fixturesFolder": "test/cypress/fixtures",
"integration": {
"integrationFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.e2e.ts","**/*.test.e2e.js"]
},
"pluginsFile": "test/cypress/plugins/index.ts",
"screenshotsFolder": "test/cypress/screenshots",
"supportFile": "test/cypress/support/index.ts",
"videosFolder": "test/cypress/videos",
"video": false,
"component": {
"componentFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.ct.ts","**/*.test.ct.js"],
"supportFile": "test/cypress/support/component.ts"
}
}
Any ideas?
CodePudding user response:
There are a few options you can use to make a script that will run only e2e or component tests with cypress run
. The easiest way would be to use the --spec
option and pass in the folder path to your e2e tests.
package.json file
[
"scripts": {
"e2e": "cypress run --spec 'test/cypress/tests/*.test.e2e.js'"
}
]
CodePudding user response:
According to the docs, Cypress configuration defines e2e
object, not integration
one.
You can try with e2e
:
{
"baseUrl": "http://localhost:8080/",
"fixturesFolder": "test/cypress/fixtures",
"e2e": {
"integrationFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.e2e.ts","**/*.test.e2e.js"]
},
"pluginsFile": "test/cypress/plugins/index.ts",
"screenshotsFolder": "test/cypress/screenshots",
"supportFile": "test/cypress/support/index.ts",
"videosFolder": "test/cypress/videos",
"video": false,
"component": {
"componentFolder": "test/cypress/tests/",
"testFiles": ["**/*.test.ct.ts","**/*.test.ct.js"],
"supportFile": "test/cypress/support/component.ts"
}
}