Skip to content

Commit 82b4fd1

Browse files
committed
test: lower the mock.module live-exports cutoff from Node 26 to Node 24
The previous fix split per Node major: `namedExports` for < 26, getter-backed `exports` for >= 26. Node 24's CI leg then failed because Node 24 *also* snapshots `namedExports` (the option is deprecated there too — only Node 22 still reads it live). A probe on Node 24.15.0: | Option | Behavior on Node 22 | 24 | 26 | | -------------------------- | ------------------- | -- | -- | | `namedExports` (live wrap) | LIVE | snapshot | (deprecated/snapshot) | | `exports` (plain spread) | option ignored | snapshot | snapshot | | `exports` (getter wrap) | option ignored | LIVE | LIVE | So the cutoff is *Node 22 only* for `namedExports`; Node 24+ has to use the getter-backed `exports` form. Lower the version branch to `NODE_MAJOR < 24` accordingly. Verified on Node 22.22.2, 24.15.0, 26.1.0: 1158 pass / 0 fail / 0 skipped each. https://claude.ai/code/session_01XWs5VsKDPMo38kskxHoiRM
1 parent 663ff4f commit 82b4fd1

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

test/implementation-option.test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ const sassEmbeddedEsmURL = resolveEsmEntry("sass-embedded");
7474
// `sassEmbedded` must propagate to the loader's view, which means
7575
// `mock.module`'s exports have to read from the wrapper *live*.
7676
//
77-
// On Node 22 / 24, `mock.module({ namedExports, defaultExport })` is
78-
// already live — internally those keys are accessed each time the
79-
// mocked module is loaded. On Node 26, the deprecated keys are gone
80-
// and the new unified `exports` option snapshots values at synthesis
81-
// time, so we have to thread reads through getters that delegate to
82-
// the wrapper.
77+
// On Node 22, `mock.module({ namedExports, defaultExport })` is live by
78+
// itself. Starting with Node 24 those options are deprecated and the
79+
// new unified `exports` option snapshots values at synthesis time —
80+
// so on Node 24+ we have to thread reads through getters that delegate
81+
// to the wrapper.
8382
const NODE_MAJOR = Number.parseInt(process.versions.node.split(".")[0], 10);
8483

8584
/**
@@ -89,7 +88,7 @@ const NODE_MAJOR = Number.parseInt(process.versions.node.split(".")[0], 10);
8988
* @returns {Record<string, unknown>} options accepted by the running Node's `mock.module`
9089
*/
9190
function mockModuleOptions(target) {
92-
if (NODE_MAJOR < 26) {
91+
if (NODE_MAJOR < 24) {
9392
return { namedExports: target, defaultExport: target };
9493
}
9594

0 commit comments

Comments
 (0)