Skip to content

test: use registerHooks() over module.register() - #67074

Open
GeoffreyBooth wants to merge 1 commit into
nodejs:mainfrom
GeoffreyBooth:test-use-register-hooks
Open

GeoffreyBooth wants to merge 1 commit into
nodejs:mainfrom
GeoffreyBooth:test-use-register-hooks

Conversation

@GeoffreyBooth

Copy link
Copy Markdown
Member

This ports the tests that register async module customization hooks, via --loader, --experimental-loader or module.register(), only as a means of exercising some other feature to use module.registerHooks() instead. It covers:

  • assertionless JSON imports and virtual JSON modules
  • module format detection and import.meta.resolve()
  • module.findPackageJSON() called from within a resolve hook
  • the require(esm) hooks graph
  • customization hooks not applying inside a ShadowRealm
  • the TypeScript loader fixture
  • the test runner coverage and CLI tests

The coverage for these features no longer depends on the async module customization hooks (module.register(), DEP0205), so those can be removed separately. Tests that exist only to exercise the async hooks themselves are left unchanged, and will be removed along with them.

Fixtures that only the ported tests used are deleted.

Refs: #62395
Refs: #62401

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner
  • @nodejs/typescript

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. strip-types Issues and PRs related to TypeScript type stripping. test Issues and PRs related to Node.js core tests and test infrastructure. labels Oct 28, 2026
Port the tests that registered async module customization hooks, via
`--loader`, `--experimental-loader` or `module.register()`, only as a
means of exercising other features to use `module.registerHooks()`
instead. This keeps the coverage for those features independent of the
async module customization hooks, which are being removed.

Tests that exist only to exercise the async module customization hooks
themselves are left as they are.

Assisted-by: Claude
Signed-off-by: Geoffrey Booth <webadmin@geoffreybooth.com>
@GeoffreyBooth
GeoffreyBooth force-pushed the test-use-register-hooks branch from 2df3dc5 to 75ea128 Compare October 28, 2026 04:47
@GeoffreyBooth
GeoffreyBooth marked this pull request as ready for review October 28, 2026 04:49
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.66%. Comparing base (ec7a28f) to head (75ea128).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67074      +/-   ##
==========================================
+ Coverage   90.65%   90.66%   +0.01%     
==========================================
  Files         797      797              
  Lines      278482   278482              
  Branches    53559    53561       +2     
==========================================
+ Hits       252445   252497      +52     
+ Misses      16393    16354      -39     
+ Partials     9644     9631      -13     

see 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@joyeecheung joyeecheung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RSLGTM

@GeoffreyBooth GeoffreyBooth added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. strip-types Issues and PRs related to TypeScript type stripping. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants