Skip to content

[Bug]: expect standalone package broken in browser bundlers (Cypress/webpack) since 30.4.0 — node: URI scheme introduced by #16077 #16161

@BoreasMun

Description

@BoreasMun

Version

30.4.2

Steps to reproduce

  1. Install Cypress (v15.x) alongside expect@30.4.x:
    yarn add -D cypress expect@^30.4.1

  2. Import expect in a Cypress support file (browser-bundled context):
    // cypress/support/commands.js
    import expect from 'expect'

  3. Run any Cypress test:
    yarn cypress run

Every test file fails to compile immediately.

Expected behavior

Cypress compiles and runs tests successfully, as it did with expect@30.3.0.

The expect package is published standalone specifically for use outside the Jest
runner (e.g. in Cypress, Playwright, or other browser-bundled test setups). It
should remain usable in those contexts.

Actual behavior

Webpack throws UnhandledSchemeError for every Node.js built-in imported with
the node: prefix in jest-util (a transitive dependency of expect):

Error: Webpack Compilation Error
Module build failed: UnhandledSchemeError: Reading from "node:path" is not handled by plugins
Module build failed: UnhandledSchemeError: Reading from "node:process" is not handled by plugins
Module build failed: UnhandledSchemeError: Reading from "node:url" is not handled by plugins
Module build failed: UnhandledSchemeError: Reading from "node:util/types" is not handled by plugins

The node: URI scheme is not handled by webpack by default. It requires an
additional plugin (e.g. NormalModuleReplacementPlugin) to resolve — but that
should not be the consumer's burden for a package that worked without it in 30.3.0.

Additional context

The regression was introduced by PR #16077 ("Node Protocol Standardization"),
which applied the unicorn/prefer-node-protocol ESLint rule across ~146 files as
a cosmetic style change. jest-util/build/index.js now contains:

const process = require('node:process');
const data = require("node:util/types");
const data = require("node:path");
const data = require("node:url");

None of these lines existed in 30.3.0. The node: prefix is a Node.js-only
convention with no functional difference at runtime in Node.js, but it is
unrecognised by webpack when bundling for browser targets.

Workaround: pin expect, jest, and babel-jest to ~30.3.0.

Environment

System:
  OS: Ubuntu 24.04
Node: 24.x
Yarn: 1.x

Packages:
  expect: 30.4.1
  jest-util: 30.4.1 (regression introduced in 30.4.0)
  cypress: 15.14.2
  webpack (Cypress internal bundler): 5.x

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions