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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

If Cypress on Windows reports Cannot read properties of undefined (reading 'replaceAll') while handling a failed test, first compare the stack trace with Cypress’s documented failure-stack enhancement bug. That defect was fixed in Cypress 15.19.0. Upgrade to 15.19.0 or later, rerun the test, and then investigate the original application or test failure that the secondary TypeError may have hidden.

Do not assume every replaceAll message is this Cypress bug. The same wording can come from your own JavaScript, including a non-global regular expression. The operating system, Cypress version, and first stack frame determine which fix applies.

The fastest safe fix

Use this sequence before changing test code:

  1. Record the Cypress version, Node version, operating system, complete stack trace, and the first application or assertion error.
  2. Check whether the failure occurs on Windows while Cypress is enhancing a test-failure stack.
  3. If it does, update the project to Cypress 15.19.0 or later.
  4. Run the same test again and compare the original failure, not just the presence of a screenshot file.
What you observe Most likely explanation Next action
Windows run, a test or site error, then a Cypress replaceAll TypeError in failure handling The Windows failure-stack enhancement defect Upgrade Cypress to 15.19.0 or later
The stack points into your application or a test helper Your code called replaceAll with an invalid value or pattern Debug that call independently of Cypress screenshots
A screenshot is present even though the run is red Screenshot capture completed before test execution reported failure Use the test result and original stack as the pass/fail evidence

What the Windows Cypress defect does

It is a secondary error, not necessarily the test’s root cause

Cypress’s changelog describes a Windows bug in which Cypress tried to enhance a test-failure stack and then called replaceAll on an undefined value. The resulting TypeError could mask the application or test error that actually caused the failure. The changelog records the correction in Cypress 15.19.0.

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

This description is narrower than “any Cypress error containing replaceAll.” Confirm the operating system, version, and stack frames before treating an incident as the documented defect.

What the issue report does—and does not—establish

Cypress issue #26142, opened March 17, 2023 and marked “Closed as not planned,” describes one Windows Server 2019 Datacenter run using Cypress 12.8.1 and Node 16.14.0. The reporter said screenshots were saved even though the run failed. Those are details of that report, not required versions for every occurrence and not proof that Node 16.14.0 causes the problem.

Capture the facts from your failing run

Print the versions

From the project directory, run:

npx cypress version
node --version

Also record whether the command was cypress open or cypress run, whether it ran locally or in CI, and the Windows edition. Keep the entire terminal output rather than copying only the final TypeError.

Read the stack from the bottom up

Find the earliest frame belonging to your application, spec, fixture, or custom command. Then identify where Cypress begins processing the failure. A Cypress-internal frame during Windows failure-stack enhancement supports the documented defect; a frame in your own helper supports an independent JavaScript problem.

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

Save the original error before rerunning

Copy the first assertion, network, application, or uncaught-exception message into the issue notes. A secondary TypeError can obscure it on screen, and a later rerun may produce a different symptom.

Upgrade Cypress to the fixed release

npm project

Install a version range that includes the fixed release:

npm install --save-dev cypress@^15.19.0
npx cypress version

The second command confirms the binary and package version Cypress will use. Commit the updated lockfile so local and CI environments resolve the same dependency.

Yarn or pnpm

yarn add --dev cypress@^15.19.0
# or
pnpm add --save-dev cypress@^15.19.0

Use the package manager already used by the repository; mixing lockfiles can make a local fix disappear in CI.

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

Rerun the smallest reproducer

Run the failing spec with the same browser, environment variables, and base URL. Start with the narrowest command your project supports, then run the full suite after the original failure is understood. Do not delete screenshots before collecting them: they can show the final rendered state even when the test subsequently fails.

Why a screenshot can exist after a failed test

Cypress provides cy.screenshot() for manual captures and can take screenshots automatically when a test fails during cypress run or CI. Capturing is asynchronous. The image can therefore be written to the screenshots directory before Cypress finishes reporting the failure. The default directory is cypress/screenshots, unless your configuration changes it.

An image proves that a capture operation produced a file; it does not prove that assertions passed, that the command after the capture ran, or that the browser completed the test successfully. Use the run’s exit status and the original stack for those conclusions.

When the message comes from your JavaScript

String patterns are valid

String.prototype.replaceAll() replaces every occurrence of a string pattern:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const cleaned = value.replaceAll(' ', '-');

If value is undefined, the call fails before Cypress can do anything useful. Trace where the value is assigned, and decide whether missing data should be rejected, defaulted, or skipped. A guard should reflect the application’s intended behavior, not merely hide the error:

if (typeof value !== 'string') {
  throw new Error('Expected value to be a string');
}
const cleaned = value.replaceAll(' ', '-');

Regular expressions must be global

When the pattern is a regular expression, JavaScript requires the global flag. This throws a TypeError:

text.replaceAll(/error/, 'warning');

This is valid:

text.replaceAll(/error/g, 'warning');

That rule is independent of the Windows Cypress defect. If the stack points to this line in a spec, support file, page object, or application bundle, fix the value or expression there rather than changing screenshot settings.

What to do if 15.19.0 or later still fails

Separate Cypress internals from test code

Run once with the full stack visible and classify the first meaningful frame. A persistent error in application code needs normal JavaScript debugging: inspect the variable immediately before replaceAll, check fixture and API response shapes, and verify that a command did not return undefined where a string was expected.

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

Check for an unrelated failure that triggers Cypress cleanup

Malformed configuration, an uncaught exception, a failed network setup, and browser startup problems can all cause Cypress to enter failure handling. The screenshot is not evidence that capture caused the defect. Preserve the earliest error and reproduce with the smallest spec that still triggers it.

Do not treat an old-version workaround as guaranteed

The available evidence establishes the release containing the fix, not a universal workaround for older Cypress versions. Disabling screenshots, changing Node versions, or deleting the screenshot folder may change the symptom without correcting the underlying failure. Upgrade first when the stack matches the documented Windows defect.

CI and reliability checks

  • Ensure the CI lockfile installs Cypress 15.19.0 or later if the defect is being investigated.
  • Archive the terminal log and the configured screenshots directory from the same run.
  • Record the command mode: automatic failure screenshots are associated with cypress run and CI, while cy.screenshot() is an explicit test command.
  • Compare exit status, assertion output, and screenshots; none of these artifacts alone replaces the others.

Troubleshooting branches

Symptom Cause to test Fix or evidence to collect
Only Windows runs show the TypeError, immediately after another failure Cypress failure-stack enhancement bug Upgrade to 15.19.0 or later and rerun
All operating systems fail at a line containing replaceAll Undefined receiver or invalid regular expression Inspect the receiver and add /g when a regex replacement is intended
Screenshot exists, but CI exits nonzero Asynchronous or automatic capture completed before failure reporting Trust the exit status and root stack for pass/fail; use the image for visual evidence
Version is fixed, but the same internal stack remains Different defect, stale binary, or a separate failure path Confirm npx cypress version, preserve a minimal reproduction, and inspect the complete trace
Changing screenshot configuration appears to help The change altered timing or hid diagnostics Restore normal capture and verify the original error before adopting a configuration change
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 your goal is simply to obtain a clean website image for documentation, monitoring, or an AI workflow rather than to debug a Cypress test, ScreenshotNeo provides a single HTTP request. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

See the ScreenshotNeo API documentation for all options, including full-page lazy-image loading, CSS-selector element captures, device and viewport controls, retina scale, PDF output, custom CSS or JavaScript, clicks, waits, request blocking, cookies, headers, authorization, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, bulk capture, usage data, and the OpenAPI specification.

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.

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}`);

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account to try it.

FAQ

Does issue #26142 define the supported Node version?

No. Its Node 16.14.0 value describes the reporter’s environment only. Use the Cypress version, operating system, and stack trace to identify this defect rather than treating that report as a compatibility matrix.

Should I delete a screenshot that was created during a failed run?

Not automatically. Keep it with the run log until you have determined whether it documents the original application failure or merely the final state before Cypress reported it.

Frequently Asked Questions

Does issue #26142 define the supported Node version?

No. Node 16.14.0 was part of that individual report, not a universal Cypress requirement.

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

Should I delete a screenshot created during a failed run?

Keep it with the run log until you know whether it helps document the original failure; a file alone does not establish test success.

The Bottom Line

Match the complete stack trace first. For the documented Windows failure-stack bug, Cypress 15.19.0 or later is the fix; for an application-level replaceAll error, correct the undefined value or regular-expression pattern in your own code.

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.