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.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
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.
Rank #2
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.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRank #3
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 runby default. SettrashAssetsBeforeRuns: falseif existing assets must remain. - No automatic failure image appears in open mode: automatic failure screenshots are documented for
cypress run, notcypress open. Use run mode when you need Cypress’s automatic failure capture. - A moved file is not reflected correctly by Cypress: in the
after:screenshothandler, return the new absolutepathafter 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.
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):
Rank #4
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.
Quick Recap
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.

