doc: add note (and caveat) for mock.module about customization hooks#62075
Open
JakobJingleheimer wants to merge 1 commit intonodejs:mainfrom
Open
doc: add note (and caveat) for mock.module about customization hooks#62075JakobJingleheimer wants to merge 1 commit intonodejs:mainfrom
mock.module about customization hooks#62075JakobJingleheimer wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
Contributor
|
Fast-track has been requested by @JakobJingleheimer. Please 👍 to approve. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So for instance, if mocking a
tsxmodule and a loader was registered via theasyncAPI (module.register(),--loader, etc), the test-runner doesn't use it and throws trying to validateformat(even though it will actually work):node/lib/internal/test_runner/mock/mock.js
Lines 650 to 653 in f8d5bad
This is mainly problem within the
ModuleLoaderitself, which checks whether sync hooks exist; when they do, it uses that chain and ignores the potential existence of registered async hooks:node/lib/internal/modules/esm/loader.js
Lines 727 to 734 in f8d5bad
The problem for the test runner was created/exposed by switching the test-runner's loader to sync registration, which ensures there's always a sync chain (causing the async chain to be ignored internally).
Geoffrey, Joyee, Matteo, and I discussed this scenario ~a year ago in Dublin. The fix is not simple.
It would need to do something like this
slack convo