Commit Graph
4 Commits
Author SHA1 Message Date
Maruthan G 9d94b6548a test_runner: mock dual-package with conditional exports
When `mock.module()` targets a package whose `exports` field maps
`import` and `require` to different files, the ESM resolver and the
CJS resolver disagree on the resolved path. Only the ESM path was
registered in `mockMap`, so `require()` of the mocked specifier
bypassed the mock and loaded the real CJS module.

Resolve the specifier through `Module._resolveFilename` from the
caller's directory in addition to the existing ESM resolution. When
the two paths differ, register the CJS path as a second key in
`mockMap` and invalidate `Module._cache[cjsPath]`, restoring it on
`restore()`. Single-resolution packages keep their existing behavior.

Fixes: https://github.com/nodejs/node/issues/58231
Signed-off-by: Maruthan G <maruthang4@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/62943
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
2026-08-21 13:09:19 -07:00
Raz Luvaton bcaf198900 test: reorder test files fixtures for better understanding
PR-URL: https://github.com/nodejs/node/pull/48787
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2023-07-26 17:16:31 +00:00
Geoffrey Booth 12c0571c8f module: move test reporter loading
Move the logic for handling --test-reporter out of the
general module loader and into the test_runner subsystem.

PR-URL: https://github.com/nodejs/node/pull/45923
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-12-22 21:40:32 +00:00
Colin Ihrig adaf602405 test_runner: add initial CLI runner
This commit introduces an initial version of a CLI-based
test runner.

PR-URL: https://github.com/nodejs/node/pull/42658
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-04-15 18:37:28 +01:00