Run your visual tests with cypress run and leave trashAssetsBeforeRuns: true enabled. Cypress then empties the configured screenshotsFolder before the run, including nested folders and every file. With the default configuration, that folder is cypress/screenshots.
Do not place reviewed visual baselines in that generated folder. Keep baselines and plugin-managed diffs in separate directories, or Cypress will treat them as disposable run assets.
The setting that clears screenshots
Cypress controls automatic cleanup with trashAssetsBeforeRuns. Its default is true, and the cleanup occurs when you execute cypress run. Before tests start, Cypress removes the entire contents of screenshotsFolder—not just PNG files, but every file and nested subfolder.
| Configuration | What happens | Typical use |
|---|---|---|
trashAssetsBeforeRuns: true |
The configured screenshots directory is emptied before a run. | Normal CI and local visual-regression runs with generated artifacts. |
trashAssetsBeforeRuns: false |
Existing files are retained and new screenshots are written alongside them. | Only when you intentionally need previous run assets. |
cypress open |
Cypress does not perform this pre-run trashing. | Interactive debugging where you want to inspect prior captures. |
The setting applies to the folder Cypress knows as screenshotsFolder. The default is cypress/screenshots, but a project can change it.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- Carefully designed questions: Ensuring a solid understanding of concepts
- Engaging activities: Offering a mix of enjoyable exercises
- Problem-solving techniques: Providing strategies for tackling challenges
- Vibrant, full-color visuals: Enhancing learning with captivating illustrations
Configure cleanup explicitly
Put the setting in your project configuration so local and CI runs use the same policy. In an ESM Cypress configuration file, use:
import { defineConfig } from 'cypress'
export default defineConfig({
screenshotsFolder: 'cypress/screenshots',
trashAssetsBeforeRuns: true,
screenshotOnRunFailure: true,
})
screenshotOnRunFailure is independent of cleanup. When it is enabled, failed tests produce diagnostic screenshots during the run; those files are still generated assets under the configured screenshots folder and will be removed at the start of the next cypress run.
Changing the folder
If your repository uses another generated-artifact location, set that path directly:
import { defineConfig } from 'cypress'
export default defineConfig({
screenshotsFolder: 'artifacts/cypress/screenshots',
trashAssetsBeforeRuns: true,
})
Use a path that is dedicated to Cypress captures. Do not point screenshotsFolder at a directory containing checked-in baselines, golden images, or reports that must survive a run.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Run the cleanup before visual regression
- Store approved baselines separately. For example, keep them under
visual-baselines/or in the location required by your comparison plugin. - Leave Cypress cleanup enabled. Confirm that
trashAssetsBeforeRunsistruein the configuration used by CI. - Start a non-interactive run. From the project root, execute
npx cypress run. - Capture the page or element. A native capture can be as simple as
cy.screenshot('checkout'); a visual plugin may expose its own command for full-page or element captures. - Compare against the baseline. The comparison tool reads the newly generated image and the approved baseline, then writes any diff where that tool is configured to place diffs.
- Publish only useful artifacts. Preserve diffs, failure screenshots, and reports needed for review. Do not use an old failure screenshot as a baseline merely because it remains on disk.
A minimal test example
describe('checkout visual regression', () => {
it('matches the approved view', () => {
cy.visit('/checkout')
cy.screenshot('checkout')
})
})
Cypress builds screenshot paths from the adjusted spec path and test name. Consequently, a screenshot can appear in a nested directory even when you supplied only a short name.
Rank #2
- Dual Functionality: Our Pocket Eye Chart set includes both the 2 eye charts, offering a versatile solution for measuring visual acuity at a distance and in limited spaces. This 2-in-1 design caters to various vision testing needs
- Compact and Convenient: Sized at 6.5*3.5 inches, these pocket eye charts are designed for portability. Whether you're a professional optometrist, student, or need a handy tool for vision tests on the go, our compact pocket eye chart set fits conveniently in your pocket
- Color Vision Test: The eye chart features Red and Green color bars, providing an easy and helpful color vision test. This additional feature enhances the versatility of our pocket eye chart set, making it suitable for a range of vision examinations
- Durable and Washable: Crafted from durable plastic, our pocket eye charts are built to last. The washable material ensures easy maintenance and hygiene, making them ideal for repeated use in optometry practices, schools, and offices
- Pupil Gauge and Non-Reflective:The plastic pocket eye chart includes a pupil gauge, adding practicality to vision examinations. The non-reflective surface ensures accurate readings. This set is a reliable tool for professionals and a handy resource for quick vision assessments
Keep baselines and diffs out of the trashable folder
Visual-regression systems commonly have three classes of files:
| File class | Recommended location | Retention policy |
|---|---|---|
| Current-run Cypress screenshots | cypress/screenshots or your configured screenshotsFolder |
Disposable; clean before each cypress run. |
| Approved baseline images | A dedicated baseline directory required by your plugin | Reviewed and versioned deliberately. |
| Diffs and review reports | A plugin diff directory or CI artifact directory | Keep for the review window, then expire according to your CI policy. |
Cypress cleanup also covers its configured downloadsFolder and videosFolder during a run. That behavior does not extend to arbitrary directories created by a visual-regression plugin. A plugin may write baselines or diffs elsewhere, and it is responsible for cleaning or retaining those files.
Why old images cause misleading comparisons
When a run starts with previous assets in the generated screenshots directory, a human reviewing CI output can mistake an old image for a current failure. Duplicate names, changed spec paths, and retries make that confusion worse. Starting with an empty generated directory gives every capture a clear relationship to the current build.
Generated screenshots, downloads, and videos are commonly excluded from source control because they can be regenerated. If your team intentionally versions visual baselines, exclude only the disposable Cypress folders—not the baseline directory.
When you should disable automatic deletion
Set trashAssetsBeforeRuns: false only when retaining prior Cypress assets is part of a deliberate workflow, such as manual forensic analysis across runs. Understand the trade-off:
Rank #3
- Old files can be mistaken for current output.
- Disk usage grows until another process removes the files.
- CI artifacts can contain unrelated images from an earlier build if workspaces are reused.
- Baselines still should not live in the screenshots folder; disabling cleanup is not a baseline-management strategy.
import { defineConfig } from 'cypress'
export default defineConfig({
screenshotsFolder: 'cypress/screenshots',
trashAssetsBeforeRuns: false,
})
If you need both retention and isolation, archive the previous generated folder before running, then point Cypress at a fresh directory. That preserves evidence without mixing runs in one active screenshots folder.
CI behavior and artifact handling
In CI, invoke the same non-interactive command used locally: npx cypress run. The cleanup happens at the beginning of that command, so a clean workspace is not a prerequisite for Cypress to remove files inside its configured asset folders.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →CI systems can restore caches or workspace artifacts before Cypress starts. If old files reappear after a successful cleanup, check whether a later step is copying archived screenshots back into the directory, or whether the visual plugin writes to a different path. Upload screenshots and diffs after the test, not before it, and give each build its own artifact namespace when your CI provider supports one.
Troubleshooting stale or missing screenshots
Old files remain after the command
First verify that you ran cypress run, not cypress open. Then inspect the effective screenshotsFolder in the configuration loaded by that command. Monorepos often have more than one Cypress config, so a different package may be running with a different path or setting.
Baselines disappeared
They were probably stored inside screenshotsFolder. Move them to the directory expected by the comparison tool and leave trashAssetsBeforeRuns enabled. If a plugin deliberately uses the Cypress folder for its own data, follow that plugin’s retention setting instead of relying on Cypress cleanup.
Rank #4
- Creating calmer and happier mornings and bedtimes for the whole family by showing your child what they need to do to get ready.
- Encourages independence and therefore boosts self esteem as children are no longer dependent on you reminding them what comes next.
- Allows for processing time - the pictures, or pecs cards for autism, don't disappear like words do and therefore these are great for children with special educational needs, autism, ADHD, speech and language delay, ASD.
- Eliminates the need for you to nag - children can see what they need to do for themselves in this routine chart.
- Pictures cards can be moved around thanks to being attached using VELCRO Brand hook and loop, meaning you can order the routine to suit your family.
The screenshots folder is empty after a passing run
That can be correct. Cypress writes screenshots only when a test calls a screenshot command or when configured failure capture produces one. A passing suite with no screenshot command may leave no files.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows 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 reinstallDiffs are still present after cleanup
Cypress removes its configured screenshots folder, not arbitrary plugin directories. Locate the plugin’s baseline and diff paths in its configuration and apply the retention policy there.
CI reports a permission error while deleting
The runner account must be able to remove files and nested directories under screenshotsFolder. Check ownership and permissions created by earlier container steps, and ensure a prior process is not holding files open. Correct the workspace permissions before rerunning; changing the visual comparison itself will not fix a filesystem failure.
A restored cache keeps bringing back images
Exclude generated screenshot, video, and download directories from caches unless you have a specific reason to cache them. Restore dependency caches, not disposable visual artifacts. If your CI system automatically restores the workspace, inspect that restore step as well as Cypress configuration.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Where visual-regression tools fit
Open-source Cypress plugins commonly perform local or CI comparisons. Hosted services can add review dashboards and commands for full-page, element, and multi-device captures. Evaluate an approach by where it executes, where baselines and diffs live, how approvals are recorded, how CI receives the result, and which capture types it supports.
Best Value
Or skip the browser setup
If you only need a clean screenshot for a comparison job, ScreenshotNeo provides a single HTTP request instead of maintaining browser-launch and cleanup code. It accepts the consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for all options, including full-page and element captures, device and retina settings, PDF output, custom CSS and JavaScript, request blocking, headers and cookies, geolocation, caching, signed links, asynchronous webhooks, bulk capture, and usage data.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The free plan includes 1,000 screenshots each month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is available on every plan, and yearly billing gives two months free. Sign up for ScreenshotNeo and start with the free allowance.
FAQ
Does Cypress clean screenshots when a test is launched from the interactive runner?
No. Automatic trashing is tied to cypress run; interactive cypress open does not perform that pre-run cleanup.
Recommended Free Tools
Can a visual plugin keep its own baselines while Cypress cleans screenshots?
Yes. Keep the plugin’s baselines and diffs outside Cypress’s configured screenshotsFolder, then apply the plugin’s own retention rules.
What should be committed to Git?
Commit reviewed baselines only when your comparison workflow requires versioned baselines. Treat generated screenshots, downloads, and videos as disposable artifacts unless your team has explicitly chosen another policy.
Frequently Asked Questions
Does Cypress clean screenshots when a test is launched from the interactive runner?
No. Automatic trashing is tied to cypress run; interactive cypress open does not perform that pre-run cleanup.
Can a visual plugin keep its own baselines while Cypress cleans screenshots?
Yes. Keep the plugin’s baselines and diffs outside Cypress’s configured screenshotsFolder, then apply the plugin’s own retention rules.
What should be committed to Git?
Commit reviewed baselines only when your comparison workflow requires versioned baselines. Treat generated screenshots, downloads, and videos as disposable artifacts unless your team has explicitly chosen another policy.
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.

