October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober 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

Common UI Testing Problems and How Cypress Helps Solve Them

A practical guide to Cypress UI test flakiness: synchronize on UI and network state, isolate tests, choose the right test scope, and investigate CI failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cypress helps make UI tests more dependable by waiting for the state they need, observing or controlling network requests, and encouraging tests that do not depend on one another. It does not eliminate flaky tests: timing races, unstable environments, shared state, and tests aimed at the wrong scope still need to be addressed in the test design.

Why UI tests become flaky

A UI test becomes unreliable when its result depends on timing or conditions outside the behavior it is meant to verify. Cypress identifies animations, API calls, test-server or database availability, dependencies, and network conditions as possible sources of failure. A test may inspect the page before a request finishes, for example, or pass locally but fail when CI runs under different network or resource conditions. Cypress documents these sources of test flake.

The fix is to make the test synchronize on meaningful application state and isolate its assumptions—not to add arbitrary delay until the failure disappears.

Use retry-ability for changing UI, not fixed sleeps

Cypress automatically retries linked queries and their assertions while waiting for the expected UI state. This is useful when rendering or a transition takes time: assert the visible outcome instead of guessing how many milliseconds it will take. Non-query commands, including actions, execute once; Cypress does not repeatedly click or type as though those commands were queries. See Cypress retry-ability.

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

For example, a test can wait for a button to become visible and assert the result after clicking it:

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

The assertions express the state the test needs. If the result also depends on a specific network response, wait for that request as described below.

Query retries and test retries are different

Query-and-assertion retry-ability waits for the UI condition within a running test. Configured test retries rerun a failed test, potentially including its hooks. Test retries are disabled by default. They can help expose or contain transient failures, but a test that depends on shared state or an uncontrolled timing assumption remains flawed even if a later attempt passes. Cypress explains test retry configuration.

Synchronize with the request that drives the UI

When content depends on an API response, alias the relevant request with cy.intercept(), wait for that alias, and then assert on the resulting UI. This ties the assertion to the event that matters instead of an arbitrary delay.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cy.intercept('GET', '/api/profile').as('profile')
cy.visit('/profile')
cy.wait('@profile')
cy.get('[data-cy="profile-name"]').should('be.visible')

cy.intercept() can inspect request URLs, headers, and bodies; stub a response body, status, or headers; delay a response; and let a test wait for a matching request. Cypress supports combining real and stubbed requests in one test. Use a stub when you need a controlled scenario, such as an error response; use the real service when the integration itself is part of what the test must verify. Avoid intercepting every request with a broad wildcard: Cypress warns that broad interception can add overhead. Details and examples are in the intercept documentation and the network requests guide.

Diagnose failures that appear only in CI

A local pass is not proof that a test is independent of its environment. Cypress identifies network-speed and local-versus-CI differences as possible causes of failures. When a CI test fails, check that it waits for the request that drives the UI, that it asserts meaningful intermediate steps, and that the CI process has not changed application state or reduced access to required resources. Cypress’s debugging guidance describes ways to investigate timing and environment issues.

For recorded CI runs, Cypress Cloud Test Replay is a documented option for examining what happened during execution. Availability depends on the Cypress Cloud setup in use; consult Cypress Cloud’s Test Replay documentation.

Keep tests independent of earlier tests

A test that passes only because a previous test left browser state behind can fail when run alone, skipped, or reordered. Give each test the setup it needs and avoid relying on another test to create its starting state. Cypress documents cleanup of browser context before each end-to-end test, and end-to-end testIsolation is enabled by default. See test isolation and writing and organizing tests.

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

Choose a test scope that proves the right thing

Component, API, and end-to-end tests answer different questions. Pick the narrowest level that can prove the behavior under test, then use other levels where you need integration coverage. Cypress describes these scopes in its testing overview.

Test type Scope and feedback What a passing test establishes What it does not establish alone
Component Focused component behavior; Cypress mounts components in a real browser and provides a focused feedback loop. The component behavior exercised under the test’s setup. That the complete application’s integrations and journeys work.
API Endpoint behavior without rendering a page. The endpoint contract or behavior covered by the test. That the UI renders or the integrated user journey works.
End-to-end An integrated user journey through the application. The exercised path across the integrated application and its configured dependencies. That every component, endpoint, or untested path works.

Component tests offer focused feedback; API tests avoid page rendering; end-to-end tests cover integrated journeys but involve more runtime and exposure to environmental variation. A healthy suite uses levels for complementary coverage rather than treating one passing component test as proof of the whole app. Read Cypress’s component testing guide.

Use accessibility checks as one layer of testing

Automated accessibility scans can flag known rule violations, such as missing labels or poor contrast. Add explicit assertions for the accessible names and semantics your interface intends to provide, and manually assess issues automated rules cannot determine. A scan is not certification or proof of full accessibility. Cypress documents plugin-based checks and Cypress Accessibility, a paid Cypress Cloud offering, in its accessibility testing guide.

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

Find the cause of slow suites before optimizing

Measure where time goes before changing tests. Cypress points to the wrong test type, repeated logins, real network calls, bloated CI setup, and resource-constrained machines as possible performance problems. Fix the actual bottleneck: avoid unnecessary network work, limit interception to relevant requests, and remove fixed waits that delay every run without making synchronization reliable. Use retries sparingly rather than turning them into a substitute for diagnosis. Cypress Cloud analytics are documented for slow and flaky tests; see test performance guidance.

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

ScreenshotNeo as an alternative for screenshot capture

Cypress is for testing application behavior. If you also need a screenshot service for capturing pages outside a Cypress test, ScreenshotNeo is an alternative to try first: it removes known cookie banners, popups, and chat widgets before capture, bills only clean shots, and offers an MCP server for AI agents.

Or skip the browser setup

Make one request to return a screenshot; replace the example URL with the page you need. See the ScreenshotNeo API documentation for options.

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

Cookie banners, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for the free plan.

Frequently Asked Questions

Should I enable Cypress test retries to fix flaky tests?

Retries are disabled by default and rerun a failed test; use them to help handle or investigate transient failures, not as a replacement for correcting the cause.

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

Can an automated accessibility scan prove my app is accessible?

No. Scans catch known rule violations, but accessibility also needs appropriate assertions and manual assessment.

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 *

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.

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
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.