Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →For a passing Cucumber scenario, call cy.screenshot() explicitly at the step where the browser shows the state you want to preserve. For a failed scenario run with cypress run, Cypress takes a failure screenshot by default; the @badeball/cypress-cucumber-preprocessor JSON reporter’s feature tests show those screenshots appearing as report attachments. Don’t depend on that preprocessor’s Cucumber After() hook to capture failures: its documentation says the hook does not run when a scenario fails.
The details depend on your Cucumber preprocessor and reporter. The behavior below is specifically grounded in the @badeball/cypress-cucumber-preprocessor JSON reporter examples, not every Cypress-Cucumber integration.
First distinguish a Cypress screenshot from a Cucumber report attachment
There are two separate outcomes to check:
- A screenshot file exists: Cypress captured an image of the browser.
- The image is attached to the scenario in the report: your Cucumber reporter included that image in its output.
A capture does not, by itself, prove that the reporter will display an attachment. Cypress handles screenshot capture; the preprocessor and reporter determine how a captured image is represented in Cucumber output. The @badeball/cypress-cucumber-preprocessor JSON reporter tests demonstrate attachment behavior for both a passing scenario that explicitly captures a screenshot and a failed scenario with an automatically captured screenshot.
Before changing code, identify the installed Cucumber preprocessor, the reporter used to produce the report, and whether the command is running Cypress interactively or with cypress run. The evidence described here is not a compatibility matrix for other adapters, reporters, or package versions. Check the documentation and tests for the versions actually installed in your project.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Attach a screenshot to a passing scenario
Cypress does not infer that every passing scenario needs a screenshot. Add an explicit cy.screenshot() call to a step that runs after the browser reaches the state you want to capture. The preprocessor’s JSON reporter feature tests also show an element capture using cy.get("div").screenshot().
Capture the current page
Put the command in an existing step definition at the appropriate point in the scenario. For example, if a step has already navigated to the page and checked that it is ready, add:
cy.screenshot();
That command captures the browser state at the moment it runs. Place it after the action and assertions that establish the state worth documenting—not before navigation or while a loading indicator still obscures the result. The surrounding step-definition syntax depends on your project’s preprocessor setup, so add the command to the step you already use rather than copying an unverified import or project scaffold.
Capture one element
When the useful evidence is a component rather than the full browser view, capture that element:
Recommended Free Tools
cy.get("div").screenshot();
Replace div with a selector that identifies the target in your application. The element needs to exist and be available when the command runs. If a page contains several matching elements, make the selector more specific so the capture targets the intended component.
For a passing scenario, the preprocessor’s JSON reporter tests show a screenshot captured in a step being included as an attachment. If you see the image file but not an attachment in your report, investigate the reporter path and its screenshot-attachment setting; adding another capture command may simply create another file.
Keep screenshots for failed scenarios
When running cypress run, Cypress automatically captures a screenshot when a test fails by default. The screenshotOnRunFailure option controls this behavior and is enabled by default. If your project has set it to false, Cypress will not take the automatic failure screenshot. Check the effective Cypress configuration before trying to solve a missing image by adding a Cucumber hook.
The @badeball/cypress-cucumber-preprocessor JSON reporter feature tests show a failure screenshot appearing as a report attachment. That makes Cypress’s automatic capture the relevant starting point for failed scenarios in this integration: let Cypress take the failure screenshot, then verify that the reporter you run includes it.
Rank #3
Do not rely on the preprocessor’s failed-scenario After hook
A common approach in generic Cucumber-JS examples is to inspect a scenario result in an After hook and attach screenshot bytes when it failed. Cucumber-JS documents an attachment API for that kind of workflow, including a media type such as image/png. But that advice does not transfer automatically to every Cypress integration.
The @badeball/cypress-cucumber-preprocessor documentation says its After() hooks do not run if the scenario fails. A failure-only screenshot implementation that depends on such a hook can therefore miss the very failure it was meant to capture. Use the Cypress run-time failure screenshot behavior for this preprocessor, and confirm how your selected reporter consumes it. Treat Cucumber-JS’s attachment API as guidance for the documented Cucumber-JS integration, not proof that the same hook pattern works in a Cypress preprocessor.
Check whether the JSON reporter is adding screenshots
The preprocessor’s JSON reporter feature tests cover an opt-out named attachmentsAddScreenshots. In the test case, setting that environment value to false disables screenshot attachments. If captures appear on disk but disappear from JSON report output, check whether this setting is being supplied by your project or test command.
The tests establish the setting and value in their own environment; they are not a full configuration reference for every installed version. Verify the supported mechanism for supplying environment values, and the accepted value type, against the version of @badeball/cypress-cucumber-preprocessor in your repository before changing configuration. Do not assume a flag used by a different formatter has the same effect.
Use after:screenshot only for post-capture file work
Cypress provides an after:screenshot Node event that fires after a screenshot image has been written to disk. Its lifecycle covers both explicit cy.screenshot() captures and failure screenshots. Use it when you need to inspect or process the resulting screenshot file after capture.
This event is not the same as Cucumber’s attach API, and it does not by itself add an image to a Cucumber report. Keep the responsibilities separate: Cypress captures and writes the image; the Node event can handle post-capture file work; the reporter determines whether the image is attached in report output. If your goal is a Cucumber attachment, confirm that the reporter supports and is configured for that output rather than expecting the event to create it.
Account for retries and multiple screenshot files
With retries enabled, Cypress takes screenshots for failed attempts and adds the attempt number to screenshot names. Multiple images for one scenario can therefore be expected: an earlier failed attempt may have a screenshot even if a later retry passes. When diagnosing what appeared in a report, distinguish the attempt’s outcome from the final scenario outcome and inspect the reporter’s output for the run you are reviewing.
If you do not want Cypress to capture failure screenshots during cypress run, the relevant control is screenshotOnRunFailure. Turning off automatic capture changes the source image available to the reporter; it is not just a display preference. Decide whether you need the file for debugging before disabling it.
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 reinstallOutdated 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 matchBest Value
Troubleshoot missing or unexpected attachments
No screenshot after a failure
- Confirm the failure occurred during
cypress run, the execution mode for which the documented automatic failure behavior applies. - Check whether
screenshotOnRunFailurehas been set tofalse. - Do not use the preprocessor’s failed-scenario
After()hook as the recovery mechanism; its documentation says that hook does not run after scenario failure.
A screenshot file exists, but the JSON report has no image
- Confirm you are using the
@badeball/cypress-cucumber-preprocessorJSON reporter behavior rather than assuming another reporter works identically. - Check whether
attachmentsAddScreenshotsis set tofalse. - Compare your installed preprocessor and reporter versions with the documentation and tests for those versions. The available examples do not establish compatibility across all releases.
A passing scenario has no screenshot
- Add
cy.screenshot()or an element screenshot to a step that actually runs in the passing scenario. - Put the call after the browser reaches the state you intend to capture.
- If the image was written but is absent from the report, troubleshoot reporter attachment handling separately from capture.
There are several images for one scenario
Check whether retries are enabled. Cypress captures failed attempts and labels retry screenshots with the attempt number, so multiple files may reflect different attempts rather than duplicate captures from one execution.
Choose the method by outcome and destination
| Need | Capture approach | What to verify |
|---|---|---|
| Image from a passing scenario | Call cy.screenshot() or an element’s .screenshot() in a step. |
The step reaches the intended browser state, and the reporter includes the capture if you need a report attachment. |
Image from a failed scenario during cypress run |
Use Cypress’s automatic failure screenshot, enabled by default. | screenshotOnRunFailure has not been disabled, and the selected reporter incorporates the image. |
| Process a screenshot after it is written | Use Cypress’s after:screenshot Node event. |
This handles post-capture file work; it does not itself attach the image to a Cucumber report. |
| Attach binary data with a Cucumber-JS hook | Follow the documented Cucumber-JS attachment API only for an integration that supports that workflow. | Do not assume the pattern works with @badeball/cypress-cucumber-preprocessor; its failed-scenario After() hook does not run. |
FAQ
Will a passing screenshot be taken automatically?
No. Add an explicit screenshot command in a step for the passing scenario.
Does after:screenshot attach the image to my Cucumber report?
No. It runs after Cypress writes the image and is for post-capture handling. Report attachment is a separate reporter concern.
Can I apply Cucumber-JS attachment examples directly to my Cypress preprocessor?
Not without checking the integration. In particular, the documented @badeball/cypress-cucumber-preprocessor After() hook does not run after a scenario fails.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsOr skip the browser setup
ScreenshotNeo is a website screenshot API, not a Cypress plugin or a Cucumber-report attachment bridge. It will not capture the in-progress state of Cypress’s test browser or insert that test artifact into a Cucumber report. It can be useful when you separately need a clean snapshot of a reachable website URL.
For that separate URL-capture task, one GET request is enough:
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 options. Before capture, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses include X-Page-Verdict and X-Billed headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Learn about ScreenshotNeo, or sign up free for 1,000 screenshots a month with no card.
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.

