Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Cypress.io is there anyway to control the test run?

My 'example-spec.js' tests under the integration folder contain 15 tests, each time the Cypress.io will run all the 15 tests written in the 'example-spec.js'. I would like to choose and specify 'which' test needs to run, maybe 1 or 2 test at a time. The reason maybe I don't want to wait to see the output of all test while adding a 'new' test. Is there any way to control the test run in Cypress.io?

enter image description here

like image 848
soccerway Avatar asked Aug 14 '18 23:08

soccerway


People also ask

How do you stop test run in Cypress?

cypress run --no-exit To prevent Cypress from exiting after running tests in a spec file, use --no-exit . You can pass --headed --no-exit in order to view the command log or have access to developer tools after a spec has run.

How do I run a specific test in Cypress?

Cypress provides two ways to test cases. Either using the Cypress UI Test Runner or from the CLI using the "cypress run" command. A specific test case can be executed on the CLI using the "--spec" option. We can change the browser for a specific test run on CLI using the "--browser" option.

Do Cypress tests run sequentially?

Using the cypress configuration we can execute cypress tests in a sequence we desire. Simply write test file names under the testFiles property in your cypress. json file, like below. On running npm test, you can see on the test runner UI that all the tests are listed from 1 to 13 in sequence.


1 Answers

I don't know if there's a way to do it from the user interface, but you can use mocha methods to run only chosen tests by:

  1. Replacing it with xit tests you want to omit
  2. Using it.skip on tests you want to omit
  3. Using it.only on single test you want to run

To skip entire context/describe suite use context.skip() or describe.skip() which are identical.

like image 100
Krzysztof Grzybek Avatar answered Oct 09 '22 10:10

Krzysztof Grzybek