October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Retry and Rerun Cypress Tests

Learn the difference between Cypress test retries, manually rerunning a spec, and optimized reruns for recorded CI builds.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To retry a failed test automatically, set Cypress’s retries option; retries are off by default. To rerun a spec after a run has finished, select it with --spec. For recorded CI runs, Cypress Cloud can also optimize reruns to repeat failed specs—or, with the required version and setup, only tests that did not pass.

Choose the right kind of retry

What you need Use When it happens
Repeat a failed test automatically Cypress test retries During the same cypress run or cypress open execution
Run one spec again after the run ends CLI --spec In a new Cypress execution
Rerun a recorded CI build while skipping work that passed Cypress Cloud Re-run optimization After the original recorded CI run completes

These options differ in timing and granularity. A retry is another attempt at a test that failed; a rerun starts work again after a run has completed.

As an Amazon Associate I earn from qualifying purchases.

Configure automatic test retries

Cypress retries are disabled by default: both runMode and openMode default to 0. Set a number to specify how many additional attempts Cypress may make after the initial attempt. Thus, retries: 2 allows up to three attempts in total. See Cypress’s Test retries guide and configuration reference.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set one count for both modes

In the project’s Cypress configuration file, set a single number to use the same retry count in interactive and headless modes:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  retries: 2,
})

Set separate counts for run and open

Use an object when you want different behavior for CI/headless runs and interactive debugging. For example, this permits two additional attempts in cypress run but none in cypress open:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  retries: {
    runMode: 2,
    openMode: 0,
  },
})

For a TypeScript configuration, import defineConfig from cypress and use the same retries object. Keep the syntax consistent with the project’s module format.

Override retries for a targeted test

Cypress also supports retry configuration for an individual test. Use that when a specific case needs a different policy, rather than raising the retry count globally for every test. The guide covers per-test configuration alongside global settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know which hooks run again

When Cypress retries a test, its beforeEach and afterEach hooks run again. A failure in a suite-level before or after hook does not trigger a test retry. Account for this when setup or teardown changes shared state.

Rerun one failed spec from the command line

From the project root, run the spec again with --spec:

npx cypress run --spec "cypress/e2e/my-spec.cy.js"

Replace the example path with the spec you want to execute. The path must match the project’s configured specPattern; a valid file that does not match that pattern will not be selected. The CLI option accepts a file or glob and can select multiple comma-separated spec paths. See the Cypress CLI reference.

Pass the option through an npm script

If an npm script wraps the Cypress command, put -- before Cypress options so npm passes them through:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npm run e2e:chrome -- --spec "cypress/e2e/my-spec.cy.js"

Use the script name defined in your project’s package.json. The command starts a new run of the selected spec; it does not resume the prior run or restrict execution to only the individual failed test inside that file.

Rerun failed work in Cypress Cloud CI

Cypress Cloud’s Re-run optimization is for rerunning a recorded CI build. It compares the rerun with the latest completed run in its rerun group, called the anchor run, and can skip work that passed there. Its behavior depends on the Cloud tier, project and organization settings, CI provider, runner version, and rerun grouping; check the current Re-run optimization documentation for availability and setup.

Choose failed specs or failed tests

  • Run only failed specs: reruns each spec containing a failure. Other tests in those specs can run again even if they passed in the anchor run.
  • Run only failed tests: is more selective and reruns tests that did not pass. This mode requires Cypress 15.21.0 or later.

The documentation lists Business or Enterprise Cloud tiers and a free trial for this feature. Confirm the current plan eligibility and project settings before relying on it.

Check CI provider and rerun grouping

Documented supported providers include GitHub Actions, Azure Pipelines, CircleCI, Bitbucket Pipelines, and GitLab CI; provider support can have version conditions. For other CI providers, Cypress documents manual setup with CYPRESS_RERUN_GROUP_ID. Before expecting passed work to be skipped, verify that the provider and runner meet the documented conditions, the project has the feature configured, and the rerun is associated with the intended group.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Investigate a recorded failure from the terminal

For recorded CI failures, Cypress Cloud CLI can retrieve run status and failure details, including screenshots and Test Replay data. Cypress documents it as available on Cloud plans including Starter at no additional cost. See Cloud CLI: Debug CI failures from your terminal.

Distinguish test retries from query retry-ability

Cypress has two different retry mechanisms. Linked queries and assertions retry together while Cypress waits for a condition; non-query commands execute once. By contrast, retries reruns a failed test attempt. See Retry-ability in Cypress.

If an assertion races a changing page, increasing test-level retries may conceal a synchronization or assertion problem. Check whether the test uses retryable queries and asserts the condition that actually indicates the page is ready.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Diagnose common problems

The failed test ran only once

Check the effective retry configuration for the mode you used. A configured runMode does not set the interactive openMode count, and vice versa; zero means no additional attempts.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A hook failed, but Cypress did not retry

Test retries are triggered by test failures, not failures in before or after hooks. Inspect suite-level setup or teardown separately; retrying the test will not address that hook failure.

The CLI says no specs were found

Confirm the working directory, exact path or glob, and configured specPattern. If you invoke Cypress through an npm script, ensure the options follow the script’s -- separator.

Cloud rerun executes more tests than expected

If the selected mode is failed specs, all tests in each failing spec may execute, including tests that passed previously. Failed-test-only reruns require Cypress 15.21.0 or later. Also verify Cloud eligibility, provider support, project settings, and rerun-group configuration.

A later attempt passes, but the failure returns

A pass on retry is evidence of a flaky test, not proof that the underlying issue is fixed. Review the failed attempt’s logs, screenshots, and environment-dependent conditions; repeated retries increase execution work and can make persistent failures less visible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

If your task is to capture a page screenshot while debugging a test or documenting its state, ScreenshotNeo provides a one-request screenshot API. It is not a Cypress retry or rerun mechanism.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners and consent notices, newsletter popups, and chat widgets are removed before capture; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up free for ScreenshotNeo.

Frequently Asked Questions

Does Cypress retry tests by default?

No. The default retry count is 0 in both run and open modes.

Does a retry rerun the entire spec?

A test retry is an additional attempt at the failed test. A CLI spec rerun runs the selected spec in a new execution.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can Cypress retry a failed before hook?

No. Failures in suite-level before and after hooks do not trigger a test retry.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.