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

A flaky Cypress test passes sometimes and fails other times without a relevant code change. Find the cause by reproducing the failure under controlled conditions, then look for nondeterministic setup, brittle selectors, guessed timing, or decisions based on a changing page. Fix the underlying dependency and verify the test alone, in its suite, and under varied load; increasing retries by itself does not make a test reliable.

What makes a Cypress test flaky?

A test is flaky when the same code produces inconsistent results across runs. Often, the test assumes a particular state, timing, or resource condition that is not guaranteed. Cypress lists animations, API calls, server or database availability, resource availability, and network issues among possible sources of race conditions. Treat these as hypotheses to investigate, not automatic explanations for every failure. Cypress’s test-retry guidance describes these failure sources.

Two different Cypress behaviors are easy to confuse:

  • Query retry-ability: Cypress re-runs linked queries and assertions until they pass or time out. Commands that are not queries execute once. This lets a test wait for the condition it needs instead of sleeping for an estimated duration. See Cypress’s retry-ability documentation.
  • Test retries: When configured, Cypress reruns a whole failed test for a specified number of additional attempts. Retries are disabled by default. A test that fails and then passes on a retry has exposed nondeterminism; that later pass does not prove the cause is fixed. See Cypress’s test-retry guidance.

How to investigate an intermittent failure

Preserve the conditions of the failure

Before changing the test, keep the failing assertion and command log, and record the browser, test data, Cypress version, operating environment, and whether the failure occurred in cypress open or cypress run. These details help distinguish a reproducible test defect from a difference in runtime conditions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Run the test at different scopes

  1. Run the suspect test by itself. If it fails alone, focus first on its own setup, synchronization, selectors, and dependencies.
  2. Run it in its spec, then in the normal suite. If it fails only alongside other tests, investigate shared state, ordering, and cleanup.
  3. Repeat the test to try to expose intermittent behavior. Cypress recommends excessive repetition; its documentation gives 100 executions as an example, not a universal or statistically meaningful threshold.
  4. Throttle network and CPU conditions to simulate different loads. A failure that appears only under slower conditions can point to a timing or resource assumption worth testing.

For each failure, note the exact command and assertion that failed, whether the page reached the expected state, and whether a preceding test or request changed the conditions. Change one suspected cause at a time so that the next run provides useful evidence.

Use the symptom to choose what to inspect

  • An element times out: Check whether the application reached the required state, whether the selector still matches the intended element, and whether the test depends on an asynchronous action that has not completed.
  • The test fails only after another test: Check for browser or server-side state left behind, ordering assumptions, and cleanup that runs only after the test.
  • The test fails under CI-like load: Reproduce with network or CPU throttling and look for guessed delays, slow dependencies, and resource assumptions.
  • The failure appears inconsistent without an obvious pattern: Preserve each run’s context and examine asynchronous requests, animation, and backend availability rather than assuming a longer timeout is the answer.

These are starting points for diagnosis, not proof of a particular cause.

Code smells that make Cypress tests flaky

1. A test relies on another test’s leftovers

Smell: A test assumes another test has logged in, created a record, or navigated to a particular page. It passes in the full suite but fails when run alone or reordered.

Fix: Make each test establish its own starting conditions and data. Cypress enables end-to-end test isolation by default, but browser isolation does not necessarily reset server-side records or other backend state. Arrange setup or reset deliberately for data that can be changed by one test and observed by another. Cypress calls test independence a best practice in its test-isolation documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Programmatic login can avoid repeating UI login steps in every test, but keep a separate test of the actual login flow so that setup shortcuts do not leave that user-facing behavior untested. Cypress discusses isolated specs, programmatic login, and controlling application state in its best-practices guidance.

2. Selectors depend on styling or implementation details

Smell: A test locates a control through a long CSS path or a class used for presentation. A markup or styling change can then break the test even when the user-visible behavior is unchanged.

Fix: Give important test targets purposeful, specific data-* attributes, such as data-cy, and select by that attribute. For example, use cy.get('[data-cy="save-profile"]') rather than a selector coupled to layout classes. Choose a project-wide convention and avoid ambiguous attributes that match multiple controls. Cypress recommends data-* attributes because they separate selectors from CSS and JavaScript changes in its best-practices guidance.

3. A fixed wait guesses when the page will be ready

Smell: The test uses a delay such as cy.wait(5000) to guess when rendering or a request will finish. If the app is slower, the guess is too short; if it is faster, the test wastes time.

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.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Fix: Assert the state the test needs. Cypress retries linked queries and assertions until they pass or time out, so a test can express a condition rather than a duration:

cy.get('[data-cy="save-status"]').should('have.text', 'Saved')

For a known network request, use an explicit request boundary and then assert the UI result. For example:

cy.intercept('GET', '/api/profile').as('getProfile')
cy.visit('/profile')
cy.wait('@getProfile')
cy.get('[data-cy="profile-name"]').should('be.visible')

The aliased wait synchronizes on a specific intercepted request; the following assertion checks that the page reached the state the test cares about. A bare time-based wait is not the same thing as waiting for a known request. See Cypress’s retry-ability documentation and its guidance on test retries and timeouts.

4. The test branches on a DOM that is still changing

Smell: The test checks whether a transient element exists and takes a different path while the client application may still be rendering or updating. The observed DOM can differ across runs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Fix: Make the application behavior deterministic, or base the decision on a stable source of truth, such as explicit test data, server state, a cookie, or local storage. For example, control an experiment with a URL parameter rather than guessing whether a changing page has rendered a particular variant. Conditional DOM checks are safe only when the page is known to have settled. Cypress explains the limits of conditional testing.

5. Required cleanup happens only after a test

Smell: A database or application reset is only in after or afterEach. If the runner is refreshed mid-test, that cleanup may not run, leaving stale data for later tests.

Fix: Put required setup or reset before each test so that the test establishes its own preconditions. First check whether Cypress’s automatic browser isolation already handles the state in question; reset server-side data separately when needed. See Cypress’s best-practices guidance.

6. More test retries are treated as the repair

Smell: A team increases the retry count, sees a later pass, and stops investigating the original failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Fix: Use retry results to make intermittent failures visible and to guide triage, not to certify a test as deterministic. When retries are configured, the count is the number of additional attempts, and beforeEach and afterEach run again for each attempt. Keep the failure history and find the test’s underlying dependency before treating the work as complete. Cypress’s retry behavior and configuration are covered in its test-retry documentation.

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

How to verify a fix

  1. Run the changed test alone, then in its spec and normal suite.
  2. Repeat it under different network and CPU conditions, including throttling. Cypress recommends repeating tests and varying load; the 100-run example in its guidance is illustrative, not a universal pass threshold. See Cypress’s advice on reproducing flaky behavior.
  3. Run relevant neighboring tests to check that the change did not introduce shared-state leakage or ordering dependence.
  4. Confirm the user-visible condition with an assertion. Do not infer that a command completed merely because a guessed duration elapsed.
  5. Record the Cypress version, browser, environment, and whether the test ran in cypress open or cypress run, so a recurrence can be compared against the original conditions.

A useful fix makes setup deterministic, selectors resilient to presentation changes, synchronization specific to the required condition, and recurring failures diagnosable. If a retry passes, retain that evidence as a signal to keep investigating rather than as the verification result.

Or skip the browser setup

If you need a screenshot of a page while diagnosing a test or documenting a failure, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return a PNG, JPEG, WebP, or PDF. For example, using cURL:

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 are accepted and more than 60 known consent platforms, newsletter popups, and chat widgets are removed before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server gives AI agents tools to take screenshots, get page information, and capture PDFs. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

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

Sign up free for 1,000 screenshots a month, with no card required.

When Cypress’s experimental flake detection is relevant

Cypress’s current documentation also describes experimental retry strategies for flake detection, including approaches that can preserve a failing result after a later passing retry or require a threshold of passing attempts. These options are experimental and may change; verify their configuration against the Cypress version your project uses before adopting them. They can help teams surface and manage flaky outcomes, but do not replace fixing nondeterministic test setup or synchronization. See Cypress’s test-retry documentation.

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.