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

To configure Cypress screenshots, set project-wide output and cleanup options in your Cypress configuration file, set reusable capture defaults with Cypress.Screenshot.defaults() in the support file, and pass cy.screenshot() options when one test needs different behavior. Automatic failure screenshots are enabled by default during cypress run, but not during cypress open. This guide follows the current official Cypress documentation checked September 29, 2026; Cypress may change defaults or APIs between releases.

Set the screenshot folder and run cleanup

Project-level screenshot settings belong in the Cypress configuration. In a CommonJS configuration file, such as cypress.config.js, the following sets a custom folder, keeps automatic failure captures on, and preserves existing artifacts between runs:

const { defineConfig } = require('cypress')

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

For an ES module configuration file, use import { defineConfig } from 'cypress' and export default defineConfig({...}) instead of the CommonJS require and module.exports. Keep the options themselves the same. The values shown above are explicit choices, not a claim that all are Cypress defaults.

Choose a folder that your test runner can collect

screenshotsFolder defaults to cypress/screenshots. Set it to a project-relative path that is easy for your local workflow and CI system to upload. Changing this folder controls where Cypress writes screenshots; it does not by itself preserve files from the previous run.

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.

Understand what cleanup removes

trashAssetsBeforeRuns defaults to true. Before cypress run, Cypress clears the contents of the screenshots, videos, and downloads folders, including nested files and directories. On Linux, the contents are emptied directly; on macOS and Windows, items are moved to the system trash or Recycle Bin. This cleanup does not run for cypress open. These behaviors are documented in the Cypress configuration reference and screenshots and videos guide.

Set trashAssetsBeforeRuns: false when a workflow deliberately accumulates artifacts across runs. That choice also means an old screenshot can remain beside a new one, so arrange a separate cleanup or use unique output locations if stale files would confuse CI artifact collection. If you want a clean result each run, leave the setting enabled and have CI upload the newly generated files after the run.

Turn automatic failure screenshots on or off

Automatic screenshots of failed tests are enabled by default during cypress run, including runs in CI. Cypress does not automatically capture test failures during cypress open. To disable run-failure screenshots for the project, set the configuration option to false:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  screenshotOnRunFailure: false,
})

You can also set screenshotOnRunFailure: false through Cypress.Screenshot.defaults(), described below. Use one place as the project’s source of truth rather than maintaining competing settings. Keep failure captures enabled when visual evidence helps diagnose CI-only failures; disable them when those artifacts are unwanted or the project has a separate capture workflow.

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.

Failure screenshots use runner capture behavior even if your normal screenshot defaults specify another capture mode. In particular, a failure screenshot is not a way to request an ordinary application-only viewport image. The automatic failure behavior is described in Cypress’s screenshots and videos guide.

Choose capture scope and shared defaults

Use Cypress.Screenshot.defaults() to establish reusable screenshot API defaults. Cypress recommends putting these defaults in the support file, which is loaded before test files are evaluated. This layer is distinct from the project-level folder and cleanup options.

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.
// cypress/support/e2e.js
Cypress.Screenshot.defaults({
  capture: 'viewport',
  disableTimersAndAnimations: true,
  blackout: ['[data-sensitive]'],
})

The option names are also available on individual cy.screenshot() calls. A command-level option can override a shared default for that capture; use that when a particular test needs full-page output or a different privacy treatment. See the Cypress.Screenshot API and cy.screenshot() command reference for the current option details.

Compare the three capture modes

Mode What it captures Useful when
viewport The application’s current viewport. You need a stable view of what is visible without capturing the whole document.
fullPage The application from top to bottom; Cypress scrolls and stitches the capture. You need one image representing a long page. Be aware that content which changes as the page scrolls can affect the result.
runner The browser viewport including the Cypress Command Log. You need runner context with a screenshot. Automatic failure screenshots are coerced to this mode.

When Test Replay is enabled and the Runner UI is hidden, a runner screenshot may show only the current application viewport. Do not assume that every runner capture will visibly include the Command Log in that configuration.

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

Stabilize captures and scaling

disableTimersAndAnimations is enabled by default during capture, helping reduce visual movement from timers and CSS animations. Set it to false if the animation itself is what the test must document, while expecting the captured frame to be more time-dependent.

scale defaults to false for application captures; runner captures coerce it to true. Cypress documents the application default as a way to avoid screenshot differences caused by display resolutions. Keep the default for visual comparisons intended to be consistent across machines unless your use case calls for scaling.

Write screenshots from a test

A test can use the default filename or supply a filename and per-capture options. For example:

it('captures the account page', () => {
  cy.visit('/account')
  cy.screenshot('account-page', {
    capture: 'fullPage',
    blackout: ['[data-sensitive]'],
  })
})

In this example, the supplied name replaces the test name in the output path, and the call requests a full-page capture. A supplied filename can include nested directories and receives a .png extension. If names collide, Cypress numbers duplicate filenames unless you pass overwrite: true. Use overwrite only when replacing the existing artifact is intentional.

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.

By default, Cypress organizes screenshots using the spec path and test name. It removes common ancestor directories among the specs included in the run to avoid unnecessarily deep paths. Consequently, the relative artifact path can vary depending on which specs ran together. Failure screenshots append (failed) to the default test-name filename. If another tool expects a fixed path, use a supplied filename and verify the path produced by your actual set of specs. Cypress documents path behavior in Writing and organizing Cypress tests and the screenshot command reference.

Mask sensitive content and control capture callbacks

For application viewport screenshots, blackout accepts CSS selectors and masks matching elements. For example, blackout: ['[data-sensitive]'] is useful if the application marks values that should not appear in a visual artifact. This option does not apply to runner captures, so it is not a universal redaction rule. Check the resulting image, particularly when switching capture modes or relying on failure screenshots.

Cypress Cloud separately documents a control for hiding Command Log content in screenshots. That is relevant to runner/log privacy, but it is not the same as masking application elements with blackout. Match the privacy control to what the image contains; neither setting should be treated as proof that every sensitive value has been removed. See Data storage and controls in Cypress Cloud.

Make synchronous page adjustments around a capture

onBeforeScreenshot and onAfterScreenshot let a test synchronously adjust the DOM around a non-failure capture. One practical use is hiding a changing clock just before taking an image and restoring or otherwise adjusting the page afterward. The after callback receives screenshot details such as the path and image dimensions. Use these callbacks when a small, reversible page adjustment makes the artifact more repeatable; do not rely on them to mask runner content.

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

Use the Node event for post-capture file work

The separate after:screenshot Node event runs after a manual or failure screenshot and can access the file system. It is the appropriate layer when post-processing or recording screenshot-file metadata outside browser test code is needed. Cypress commands cannot be called from this event handler; it runs in the Node event context, not as a chain of browser-side cy commands. The event and metadata are documented in the after:screenshot event reference.

Pick settings by workflow

Need Recommended setting or approach Trade-off to check
Clean artifacts for each CI run Keep trashAssetsBeforeRuns: true and collect artifacts after the run. Previous screenshots, videos, and downloads are cleared by cypress run.
Retain files between CI runs Set trashAssetsBeforeRuns: false and manage artifact naming or cleanup yourself. Old files may be mistaken for output from the current run.
Capture the visible application Use capture: 'viewport'. Content outside the current viewport is excluded.
Capture a long page Use capture: 'fullPage'. Cypress scrolls and stitches; scrolling content may change during capture.
Include runner context Use capture: 'runner'. blackout does not apply to runner captures; failure captures already use runner behavior.
Reduce visual movement Leave disableTimersAndAnimations enabled and use Cypress’s default application scaling. Disabling animation may not suit a test whose purpose is to capture motion.

Troubleshoot common screenshot issues

No automatic screenshot appears after a failure

  • Confirm the test ran with cypress run; Cypress does not automatically capture failures in cypress open.
  • Check that screenshotOnRunFailure has not been set to false in project configuration or screenshot defaults.
  • Look in the configured screenshotsFolder, not only the default cypress/screenshots directory.

Earlier screenshots disappeared

Check whether trashAssetsBeforeRuns is still true. That option clears the contents of screenshot, video, and download folders before cypress run; changing the screenshot folder alone does not disable cleanup. Turn cleanup off only if you have a deliberate plan to avoid stale artifacts.

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

The output file is in an unexpected directory

Inspect the full path, including the spec and test-name segments. Cypress trims common ancestor directories based on the specs in that run, so running a different subset can change the relative path. If downstream collection requires a predictable name, provide a filename to cy.screenshot() and confirm the resulting file location.

The screenshot does not hide a sensitive element

Verify that the element matches the CSS selector, and confirm the capture is an application viewport capture. blackout does not apply to runner captures. For Command Log privacy, review the Cypress Cloud data controls and inspect the produced image rather than assuming application masking covers runner content.

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

The image is different on another machine

Check whether the difference comes from animation, timers, viewport dimensions, or scale. Cypress disables timers and CSS animations by default during capture, while application scaling defaults to false. Specify a consistent viewport in the test setup and avoid opting back into live animation unless it is part of the scenario being tested.

A callback or event cannot call cy

Use onBeforeScreenshot or onAfterScreenshot for synchronous DOM adjustments. Use after:screenshot for Node-side file handling, and do not call Cypress commands from that event handler.

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

Or skip the browser setup

Cypress’s screenshot features capture a Cypress-controlled test run; ScreenshotNeo is a separate website screenshot API and MCP server for capturing a URL without configuring a Cypress browser project. Its one-request API is not a replacement for Cypress test-failure artifacts or assertions. For a standalone site capture, you can request an image like this; the response is saved as shot.webp:

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 parameters and response behavior. ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.

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.

The free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo’s free plan to try URL-based captures.

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.

Plan for artifacts, runtime, and cost

Cypress screenshot configuration does not remove the need to manage artifact storage in CI. Decide whether each run should clear its output, whether you need artifacts from failed tests only or manual captures too, and which files the CI system should retain. Preserving files can simplify comparisons across runs but requires your pipeline to distinguish current artifacts from old ones. Automatic cleanup provides a cleaner run directory but removes previous output from the configured asset folders.

Use the narrowest capture that answers the debugging question: viewport captures avoid the larger image of a stitched full page, while full-page captures are useful when the bug is below the fold. This is a workflow consideration rather than a promise of a particular speed or storage saving; Cypress’s official documentation cited here does not establish a fixed runtime or artifact-size figure. Likewise, it publishes the configuration behavior described above, not a universal cost or performance benchmark. Measure artifact volume and run impact in your own project before changing CI retention policy.

For investigations that need a reproducible visual, pair a stable viewport and consistent test state with the chosen capture mode. For privacy-sensitive workflows, inspect representative artifacts in CI, including failure captures, because the capture mode can differ from the one used by ordinary manual screenshots.

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

Official references

Frequently Asked Questions

Can I save Cypress screenshots as JPEG or WebP using these settings?

The documented Cypress screenshot command writes PNG files. The filename behavior described here appends a .png extension; this guide does not establish a JPEG or WebP output option.

Do these settings require a particular Cypress release?

The official pages referenced here describe the current documentation checked September 29, 2026, but do not establish a precise release version for every option. Confirm the configuration reference for the Cypress version installed in your project.

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.