Skip to main content
aaronwilliams.me logo

Rerun Cypress Tests Until Failure

Use the cypress-repeat module when debugging flaky tests or verifying that a new test is stable under repeated runs.

When using cypress-repeat the test runner terminates on the first failure by default.

Install as a development dependency or globally if preferred.

npm install -D cypress-repeat

Run Tests n Times Until Failure

npx cypress-repeat run \
  -n 5 \
  --spec cypress/e2e/your-test.cy.ts

This executes all tests in the spec file up to five times.

Use Cypress .only or .skip to limit which tests are executed.

Run Tests n Times Until Pass

npx cypress-repeat run \
  -n 5 \
  --until-passes \
  --spec cypress/e2e/your-test.cy.ts

The --until-passes flag reverses the logic and stops once the tests pass.

Burn with @cypress/grep

If you already use @cypress/grep then you can achieve something similar by burning filtered tests multiple times.

npx cypress run \
  --env grep="Your test",burn=5

This runs the matched test five times.