Reputation: 2753
I used to use Cypress 9 on previous projects.
By default, when running cypress open
or cypress open --browser chrome
used to run all tests for all React components.
However I installed Cypress 10 for the first time on a project that didn't have e2e tests yet. I added test specs, but I don't see any option to run all tests altogether.
It seems I have to run the tests one by one, clicking on each of them.
Can anyone please suggest how do I run all the tests automatically?
Upvotes: 49
Views: 32556
Reputation: 1
You can try this command in the terminal with npx cypress run --spec "cypress/e2e/examples/*.js"
. This works for me.
Upvotes: 0
Reputation: 101
Running All Spec Files in Cypress: Three Approaches
➡️ Process 1: Enable experimentalRunAllSpecs:true
In your cypress.config.js or cypress.json, enable the experimentalRunAllSpecs option.
e2e: {
experimentalRunAllSpecs:true,
baseUrl: "https://opensource-demo.orangehrmlive.com/",
setupNodeEvents(on, config) {
},
},
➡️ Process 2: Run Cypress in the Command Prompt
Use the following command to run all Cypress scripts:
npx cypress run
➡️ Process 3: Create a New Spec File
Create a new spec file.
Import all the spec files into the created file:
import './its.spec.cy';
import './scroll.spec.cy';
import './eqIts.spec.cy';
Add the file path in the spec pattern.
e2e: {
specPattern:"cypress/e2e/testFiles.spec.cy.js",
baseUrl: "https://opensource-demo.orangehrmlive.com/",
setupNodeEvents(on, config) {
},
},
Using this approach, in both the dashboard and headless modes, Cypress will only run the specified file and execute all test cases in one run.
Upvotes: -3
Reputation: 547
In Cypress version 11.2.0 the Run All button has been reinstated.
You need to set experimentalRunAllSpecs
to true in cypress.config.js
.
Please see Configuration - End-to-End Testing
Upvotes: 51
Reputation: 32148
It's been removed in Cypress v10, here are the change notes related
During cypress open, the ability to "Run all specs" and "Run filtered specs" has been removed. Please leave feedback around the removal of this feature here. Your feedback will help us make product decisions around the future of this feature.
The feedback page to register your displeasure is here
You can create a "barrel" spec to run multiple imported specs.
I can't vouch for it working the same as v9 "Run all tests", but can't see any reason why not.
// all.spec.cy.js
import './test1.spec.cy.js' // relative paths
import './test2.spec.cy.js'
...
As @Constance says, reinstated in v11.20.
But still a very handy technique if you want to run a pre-defined subset of your tests.
Upvotes: 54
Reputation: 2658
It was removed because people used it wrong.
The Test Runner is for debugging single tests. But by running all tests, then performance will quickly become a problem and crash the entire suite.
Running all tests should only be performed from the CLI.
Sources
Upvotes: -3
Reputation: 19
As per the feedback discussion there is a workaround the same as @Fody's answer that will achieve the same result as v9. Also worth noting though is the section on Continuous Integration and the Update 1 that includes a fix for preventing this workaround creating issues with the cypress run
command.
Are there any current workarounds?
- Yes. If you are impacted by the omission of this feature, it is possible to achieve the same level of parity as 9.x with a workaround Gleb Bahmutov explains here: https://glebbahmutov.com/blog/run-all-specs-cypress-v10/
- This will still inherit the same problems as the previous implementation (which is why it was removed) but it will work in certain cases where the previous implementation was not problematic for your use case
https://github.com/cypress-io/cypress/discussions/21628#discussion-4098510
Upvotes: 1
Reputation: 308
If Cypress Test Runner is not a must, I suggest to utilize the CLI/Node Cmd approach
You can trigger all the test(s) by npx cypress run
(Still the video recording & screenshot on failed steps would be saved in the respective folders) to run all or with any other cypress flags to filter out specific spec files, or browser etc.
Upvotes: 2