I have different different specs file in below structure
login.cy.js
- describe
-- it.Test Valid Login
-- it.Test Invalid Login
dashboard.cy.js
- describe.verifyDashboard
-- it.verify loggedin user
-- it.verify user data
addNewUser.cy.js
- describe.verifyURL
-- it.navigateToAddUserPage
-- it.fillAllTheDetails
-- it.SubmitForm
I have already set experimentalRunAllSpecs: true
in config file and I’m able to run all the specs in sequentially from GUI mode but the problem is that, it does not run all specs when running from command line. It only execute 1st login.cy.js
and rest of specs are getting failed and does not navigate to url which I have visited in login.cy.js
. However, login.cy.js
is executed and passed successfully.
Since your tests are tight coupled (dependent on one another), you can try turning off test isolation.
Please read this page https://docs.cypress.io/guides/core-concepts/test-isolation to get the full picture, it includes some caveats about this style of testing.
If you want to keep the coupling, you may still need to build a “runner” test by importing the other tests
sequential-run.cy.js
import './login.cy.js'
import './dashboard.cy.js'
import './addNewUser.cy.js'
and specify it on the command line
npx cypress run --spec cypress/e2e/sequential-run.cy.js
This is what is is happening when you use experimentalRunAllSpecs
in the test runner – it builds a dummy spec of all the specs shown in the runner.