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

How to Change the Screenshot Path in Cypress Configuration

Change Cypress’s screenshot output base directory with screenshotsFolder, and learn how spec paths, run cleanup and after:screenshot affect the final files.

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.

Set Cypress’s screenshotsFolder option to change the base directory for screenshots. It applies to files created by cy.screenshot() and automatic failure screenshots during cypress run. The default is cypress/screenshots.

Set the project-wide screenshot folder

Add screenshotsFolder to the object passed to defineConfig() in your Cypress configuration file. For example, in a CommonJS JavaScript configuration:

As an Amazon Associate I earn from qualifying purchases.

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  screenshotsFolder: 'artifacts/cypress-shots',
})

Use the same option in the exported defineConfig() object in a TypeScript configuration. The path is relative to the project unless you provide an absolute path. Cypress documents cypress/screenshots as the default. Cypress configuration reference

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

Understand where Cypress puts each image

screenshotsFolder sets the base directory, not always the complete image path. Cypress builds paths beneath it from the spec file and screenshot name. For instance, passing actions/login as the name to cy.screenshot() creates a nested directory under the applicable spec path. Cypress screenshot command

Cypress also removes the shared ancestor among specs when it forms generated asset paths. As a result, a screenshot from the same spec can appear at a different nested path if the set of specs included in a run changes. Avoid assuming the full generated path will be identical across differently scoped runs. Cypress screenshots and videos guide

Keep screenshots between test runs

Before cypress run, Cypress clears the contents of the screenshots folder by default; it preserves the folder itself. If you need existing generated files to remain, set trashAssetsBeforeRuns: false in the Cypress configuration. Cypress configuration reference

Automatic screenshots of failed tests are documented for cypress run. Cypress does not automatically capture failure screenshots during cypress open. Cypress screenshots and videos guide

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.

Choose between a base folder and custom relocation

Approach Use it for Where it is configured Path handling
screenshotsFolder Changing the normal project-wide base directory Cypress project configuration Cypress constructs paths beneath the base from the spec and screenshot name.
after:screenshot Custom Node-side handling after an image is captured, such as moving a file setupNodeEvents in the Cypress configuration After moving the file, return its new absolute path so Cypress knows its updated location. Cypress after:screenshot event

Use after:screenshot only when changing the base folder is not enough and you need custom post-capture handling. For ordinary output-directory changes, screenshotsFolder is the direct setting.

Troubleshoot unexpected screenshot paths

  • The file is nested beneath the configured folder: Check the spec-relative path and the name passed to cy.screenshot(); both can contribute directories or filename components.
  • The same spec appears at a different path in another run: The shared ancestor among the specs in a run affects the generated asset path. Compare which specs were included.
  • Earlier screenshots disappeared after a run: cypress run clears screenshot-folder contents by default. Set trashAssetsBeforeRuns: false if those contents must remain.
  • A failure screenshot is missing in the interactive runner: Automatic failure capture is documented for cypress run, not cypress open.
  • You moved a screenshot in an event handler but Cypress has the old location: Return the new absolute file path from the after:screenshot 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

If you need a website screenshot rather than Cypress test artifacts, ScreenshotNeo takes one with a GET request. Cookie banners, newsletter popups and chat widgets are removed before the shot; bot checks, blank pages and failed loads are never billed. AI agents can use its MCP server for screenshots. It includes 1,000 screenshots a month free with no card, and paid plans start at $5 for 3,000.

cURL example (see the ScreenshotNeo documentation):

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

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

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

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
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair 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.