Skip to content
Branch: master
Find file History
bahmutov Clean up readme - remove duplicate feature lists (#299)
* move first list

* more lists

* more examples moved

* move more

* more examples

* update all blog recipes

* add two items

* move unit testing readme

* even lists moved

* more work

* more moved
Latest commit e509f00 Jun 12, 2019


Run Cypress via its module API

Cypress provides a Node module in addition to its CLI commands.

See module API documentation

  // options
}).then(testResults => {
  // rerun failing specs
  // or email test report
  // or post it on Slack
  // ...


In this recipe, execute npm run cypress:run script which calls e2e-tests.js that finds all spec files in cypress/integration, sorts them by the last modified timestamp and runs them using Cypress one by one.

For example, if I add a comment to second-spec.js, then it will be executed first

npm run cypress:run

Running last modified spec first
filename                              time
------------------------------------  -------------
./cypress/integration/second-spec.js  1555069051000
./cypress/integration/third-spec.js   1555067795000
./cypress/integration/first-spec.js   1555067777000

Cypress output for each spec file

Test run summary
spec            tests  passes  failures
--------------  -----  ------  --------
second-spec.js  1      1       0
third-spec.js   1      1       0
first-spec.js   1      1       0

Note: this only uses the file system modified time, thus does not work with files checked out from a Git repository - they all will have the same modified timestamp.

You can’t perform that action at this time.