I have a very large Cypress-based test suite, cy_tests_A_B_monolith, and the number of tests in ./cypress/integration folder is substantial.
I wish to partition these integration tests into their own npm module, and make them dependencies of a more manageable Cypress test suite.
cy_tests_A_B_monolithcy_tests_A_B_manageable + dependencies cy_test_A + cy_test_BRough draft below. Uncertain how to import ./cypress/integration/*** tests to be a dependency into another Cypress test suite.
Much appreciated for suggestions, Thank you.
Rough Draft:
FROM monolith
Many integration tests + src custom commands...
npm cy_tests_A_B_monolith
├── cypress
│ ├── integration
│ │ ├── A
│ │ └── B
│ └── support
│ └── specs
│ ├── A
│ └── B
├── src
│ ├── A
│ | └── commands
│ └── B
│ └── commands
TO...
Partitioning monolith into a manageable test suite by maintaining subset of /cypress/integration of monolith test suite
npm cy_tests_A_B_manageable
├── cypress
│ ├── integration
│ │ ├── A << dependency imported cy_test_A ./cypress/integration/A
│ │ └── B << dependency imported cy_test_B ./cypress/integration/B
npm cy_test_A
├── cypress
│ ├── integration
│ │ └── A
│ └── support
│ └── specs
│ └── A
├── src
│ └── A
│ └── commands
npm cy_test_B
├── cypress
│ ├── integration
│ │ └── B
│ └── support
│ └── specs
│ └── B
├── src
│ └── B
│ └── commands
It's a little bit funky, but you can us the Module API in cy_tests_A_B_manageable to drive tests from other projects
/scripts/run-cypress.js
const cypress = require('cypress')
const testProjects = ['../cy_test_A', '../cy_test_B']
testProjects.forEach(project => {
cypress.run({
reporter: 'junit',
browser: 'chrome',
project, // can specify the project root here
config: {
video: false,
},
env: {
login_url: '/login',
products_url: '/products',
},
})
})
With cypress open it opens multiple runners, not ideal...
But can use cypress.open(...) with this folder setup
cypress-multi-project
- cy_test_A
- cy_test_B
- cypress-run-other-project
cypress-multi-project/cypress.json
{
"integrationFolder": "./",
"testFiles": "**/*.spec.js" // must uniquely suffix integration tests
}
cypress-multi-project/cypress-run-other-project/scripts/run-cypress.js
const cypress = require('cypress')
cypress.open({
reporter: 'junit',
browser: 'chrome',
project: '..', // project is parent folder
config: {
video: true,
},
env: {
login_url: '/login',
products_url: '/products',
},
})

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With