Run All Specs in Cypress v10

How to run all or some specs using Cypress v10 where the Run all specs button has been removed.

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.

Running one spec at a time using Cypress v10

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.

cypress/e2e/all.cy.js
1
2
3
import './clock.cy'
import './play.cy'
import './spec.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.

Running all specs together

Want to run just the test files "spec.cy.js" and "clock.cy.js" together? Comment out the "play.cy" import

cypress/e2e/all.cy.js
1
2
3
import './clock.cy'
// import './play.cy'
import './spec.cy'

Skipping the play.cy.js spec file

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

cypress.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
excludeSpecPattern: process.env.CI ? ['cypress/e2e/all.cy.js'] : [],
},

component: {
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
},
},
})

If we run the tests locally using cypress run we see 4 specs included

All specs are included by default

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.

The all.cy.js spec file skilled on CI

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.

cypress.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
module.exports = defineConfig({
projectId: '1qsjjk',
e2e: {
baseUrl: 'http://localhost:3000',
setupNodeEvents(on, config) {
if (config.isTextTerminal) {
// skip the all.cy.js spec in "cypress run" mode
return {
excludeSpecPattern: ['cypress/e2e/all.cy.js'],
}
}
},
}
})

Update 2: Run All Specs button is back

In Cypress v11.2.0, watch the video Run All Specs Button Is Back In Cypress v11.2.0 to see it in action.