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

Set screenshotsFolder in your Cypress configuration to change the base directory for screenshots. Cypress uses it for both images created with cy.screenshot() and automatic failure screenshots during cypress run. The documented default is cypress/screenshots. Cypress configuration reference

Set the project-wide screenshot folder

Edit your Cypress configuration file and add screenshotsFolder to the object passed to defineConfig. For example, in a CommonJS JavaScript configuration:

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 value is a base directory, usually expressed relative to the project root. Cypress creates it as needed.

This setting applies to manual screenshots from cy.screenshot() and failure screenshots produced during cypress run. Cypress does not automatically capture failure screenshots during cypress open; the documented automatic failure capture is for run mode. See the configuration reference.

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

Understand the final image path

screenshotsFolder selects the base directory, not necessarily the full path of each image. Cypress builds paths beneath it using the spec file path and, when supplied, the screenshot name. For example, a screenshot named actions/login can create a nested directory under the relevant spec path. The generated path can also change depending on which specs are included in a run because Cypress removes the shared ancestor among the specs when forming asset paths. See the screenshot command documentation and the Cypress test-retries guide.

Consequently, do not assume every image will be written directly to artifacts/cypress-shots. If your scripts or CI artifacts depend on exact filenames, inspect the actual paths produced for the set of specs being run.

Keep existing screenshots between runs

By default, Cypress clears the contents of the screenshots folder before cypress run. The folder remains, but previously generated files inside it are removed. If you need to retain existing screenshot assets, set trashAssetsBeforeRuns: false in the project configuration:

const { defineConfig } = require('cypress')

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

That option prevents Cypress from clearing run assets before the run. See the configuration reference.

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

When to move a screenshot after capture

Use screenshotsFolder when you want to change the normal project-wide base directory. If you instead need custom Node-side handling after each screenshot—such as moving a file to a destination determined at runtime—use the after:screenshot event in setupNodeEvents. After moving the file, return its new absolute path so Cypress knows its updated location. See the after:screenshot event documentation.

Approach Best for Where to configure Path handling
screenshotsFolder Choosing the normal base folder for project screenshots Cypress project configuration Cypress still adds spec-relative and optional screenshot-name paths
after:screenshot Custom post-capture handling, including relocating a file Node event handler in setupNodeEvents Return the new absolute path after moving the file

Common problems and fixes

  • The image is not directly in the configured folder: Cypress may add a spec-relative path and a nested path from the screenshot name. Check the complete generated path, not just the base folder.
  • Previous screenshots disappeared after a run: Cypress clears screenshot-folder contents before cypress run by default. Set trashAssetsBeforeRuns: false if existing assets must remain.
  • No automatic failure image appears in open mode: automatic failure screenshots are documented for cypress run, not cypress open. Use run mode when you need Cypress’s automatic failure capture.
  • A moved file is not reflected correctly by Cypress: in the after:screenshot handler, return the new absolute path after the move.
  • The generated path differs between runs: Cypress removes the shared ancestor among specs when constructing asset paths. The resulting nested path can therefore vary with the set of specs included.
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 screenshots of web pages rather than Cypress test-run artifacts, ScreenshotNeo takes a screenshot with one GET request. Its API removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. It also offers an MCP server so AI agents can take screenshots.

Example using cURL (see the ScreenshotNeo API documentation):

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

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

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.

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.