Note: Cypress v10 has removed the "Run all" specs button because of its technical limitations, see the Be careful when running all specs together blog post. You can voice your feedback by commenting on the issue #21628. This blog post explains my workaround for running all specs together (or some specs only).
Video: if you would rather watch the explanation, I have recorded the video "How To Run All Specs In Cypress v10" below, part of my Cypress Tips & Tricks Playlist.
Let's say I have 3 End-to-End spec files. I can run each spec by clicking on it.
Ok, so how do I run all 3 specs together? Hmm. That is a conundrum.
Here is what you do. Create a new e2e spec that just imports all other specs.
1 | import './clock.cy' |
Click on the "all.cy.js" spec in Cypress and voilà - you got all your specs running together, just like the good old days.
Want to run just the test files "spec.cy.js" and "clock.cy.js" together? Comment out the "play.cy" import
1 | import './clock.cy' |
Continuous integration
What about the CI? We don't want to run all specs individually AND run them again by hitting the all.cy.js
spec file on CI? You can exclude the all.cy.js
when running the tests on CI
1 | const { defineConfig } = require('cypress') |
If we run the tests locally using cypress run
we see 4 specs included
But when we simulate the Continuous Integration server by setting the CI=1
environment variable we see the all.cy.js
spec file skipped, so only the real test files run.
Happy Cypress v10 testing
PS: it would be nice to know in the cypress.config.js
file if we are running using the cypress open
or cypress run
mode.
Update 1: skip the all.cy.js spec when using the cypress run command
I have recorded a video showing how to automatically ignore the all.cy.js
spec when using the cypress run
command. Hint: we will use the config.isTextTerminal
property to determine if Cypress is running using cypress run
or cypress open
mode.
In short, you can return changed config options from the setupNodeEvents
method. To determine the run
mode you can look at the config.isTextTerminal
property.
1 | module.exports = defineConfig({ |
In Cypress v11.2.0, watch the video Run All Specs Button Is Back In Cypress v11.2.0 to see it in action.