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 desk5 min

How to Improve Error Screenshots in Cypress

Make Cypress failure screenshots more useful: understand run-versus-open behavior, capture verified states, inspect retries, locate artifacts, and know when to use video or visual testing.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cypress already captures a screenshot when a test fails in cypress run: screenshotOnRunFailure defaults to true, and images go to cypress/screenshots unless you change screenshotsFolder. Failures in interactive cypress open do not get automatic failure screenshots. To make the evidence more useful, capture deliberately after the app reaches a verified state, then use retry artifacts, video, or Test Replay when a still image cannot explain what happened. Cypress documents the automatic and manual screenshot behavior.

Check Cypress’s automatic failure screenshots first

For test runs, Cypress’s default is to capture a failure screenshot. The documented defaults are screenshotOnRunFailure: true and screenshotsFolder: 'cypress/screenshots'. You can set them explicitly in the project configuration file if your team wants the behavior to be obvious:

As an Amazon Associate I earn from qualifying purchases.

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  screenshotOnRunFailure: true,
  screenshotsFolder: 'cypress/screenshots',
})

This configures whether and where Cypress saves the automatic captures; it does not make an image show more useful app state. In cypress open, failure screenshots are not automatic, so use cy.screenshot() when you need a manual capture. See the current Cypress configuration reference for the options and defaults.

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.

Capture at a useful, verified point in the test

A manual screenshot is most helpful after an assertion proves the state you want to inspect. Give it a descriptive name so the artifact is recognizable:

cy.contains('Saved').should('be.visible')
cy.screenshot('saved-state')

This example captures after Cypress confirms that the success text is visible. Adapt the assertion to the actual state under investigation—for example, an error message, a completed form, or a modal. A screenshot alone does not prove that the application is correct; the preceding assertion is what establishes the intended checkpoint.

Cypress coordinates screenshots with the application on a best-effort basis. If the page is still rendering, waiting on a request, animating, or changing asynchronously, the captured frame can show an intermediate state. Synchronize on observable app state and control test data and timing where practical. Cypress’s visual testing guidance also cautions that captures during rendering, animation, or data loading can produce misleading visual results.

Choose the capture scope that answers the debugging question

cy.screenshot() supports three useful capture scopes. Pick the smallest scope that preserves the context you need:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Capture What it shows Useful when
viewport The application’s current browser viewport. You need to inspect the visible state at the point of failure.
fullPage The page from top to bottom, captured by scrolling and stitching. The relevant content may be outside the viewport. Fixed or sticky elements can appear more than once in the stitched image.
runner The browser viewport together with the Cypress Command Log. You need app state and runner context together. Cypress uses runner capture for failure screenshots.

See the Cypress.Screenshot API for capture options and behavior. A runner screenshot can help orient you, but do not assume the Command Log will display the error in the still: Cypress notes that the log may render asynchronously.

Use retries to tell intermittent failures from repeatable ones

When retries are enabled, Cypress can save screenshots for failed attempts, with attempt-number suffixes such as (attempt 2). Compare the attempt artifacts: a failure that recurs with the same visible state suggests a repeatable problem, while differing images can point to timing, data, or state variation. Retries provide diagnostic evidence; they do not fix the underlying failure. Cypress allows retry behavior to be configured separately for runMode and openMode. Details are in the test retries guide.

Find artifacts without guessing their full paths

Cypress mirrors spec-file paths beneath its artifact directories, so a deep path can depend on the spec and configuration. The resolved screenshot path is available through the callback to cy.screenshot() or through the after:screenshot and after:spec Node events. Prefer those resolved paths over a hard-coded guess when a script needs to copy or process artifacts. Cypress explains artifact organization in Writing and organizing tests.

Also account for cleanup: trashAssetsBeforeRuns defaults to clearing the downloads, screenshots, and videos folders before a cypress run. If your workflow depends on keeping artifacts across runs, review that setting in the configuration reference.

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

When a screenshot is not enough

A screenshot is a still, not a record of the sequence that caused the failure. If the issue depends on an event order, transient state, or a race, use video or Test Replay to inspect more of the run. Cypress’s screenshots and videos guide describes those artifacts and Test Replay.

If your actual goal is to detect unintended UI changes against an approved baseline, that is visual regression testing, not simply taking a better failure screenshot. Cypress states: “Cypress does not perform image comparison itself. The built-in cy.screenshot() command captures images but does not compare them.” Its visual testing documentation lists integrations including Applitools, Chromatic, Percy, and Sauce Labs Visual. Evaluate the integration’s Cypress compatibility, browser coverage, baseline storage, masking, review process, and CI fit for your workflow.

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

Troubleshoot unhelpful or missing screenshots

  • No automatic screenshot after failure: Confirm the test ran with cypress run, not only cypress open, and check that screenshotOnRunFailure has not been disabled.
  • Artifact missing after a later run: Check whether trashAssetsBeforeRuns cleared the screenshots directory before that run.
  • The image shows loading or stale content: Add an assertion for the state that matters and wait for the relevant app condition before calling cy.screenshot(); avoid relying on an arbitrary delay when an observable condition is available.
  • The failure details are absent from the capture: The Command Log may not have rendered in time for the still image. Use video or Test Replay to recover sequence and context.
  • Full-page capture has repeated headers or controls: Cypress stitches the image while scrolling; fixed and sticky elements can recur. Use viewport capture if the repeated elements obscure the evidence.
  • A script cannot find an artifact at its expected path: Avoid inferring a deep path from the spec name. Read the resolved path from the screenshot callback or the after:screenshot or after:spec event.

Or skip the browser setup

If you need a website capture outside the Cypress test runner, ScreenshotNeo is a screenshot API with a one-request capture. For example, this cURL call saves a WebP capture of Stripe:

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. It accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

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

Sign up free for ScreenshotNeo to start with 1,000 screenshots a month and no card.

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

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.