-
-
Notifications
You must be signed in to change notification settings - Fork 32k
test_runner: mock_loader resolve the cjs and esm formats respectively. #53846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aduh95
merged 10 commits into
nodejs:main
from
syi0808:fix/module-mock-throw-error-wrong-import
Aug 6, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
44aa3e3
test_runner: replace cjs resolve to defaultResolve
syi0808 729a8ac
test_runner: divert resolve logic by type
syi0808 4a26832
test_runner: get format from parentURL as default or pass specifier a…
syi0808 45e4ea7
test_runner: test change to using exist file
syi0808 4d3247e
test_runner: use common.spawnPromisified instead of child_process
syi0808 61439ba
test_runner: use resolveFilename instead of createRequire
syi0808 45fb6b1
test_runner: remove module extension from imported file in fixture
syi0808 98870be
refactor: if to optional chaining
syi0808 a6ad04e
refactor: test move to module-mocking
syi0808 83adb9a
formatting
syi0808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export let string = 'original esm string'; |
8 changes: 8 additions & 0 deletions
8
test/fixtures/module-mocking/wrong-import-after-module-mocking.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { mock } from 'node:test'; | ||
|
||
try { | ||
mock.module?.('Whatever, this is not significant', { namedExports: {} }); | ||
} catch {} | ||
|
||
const { string } = await import('./basic-esm-without-extension'); | ||
console.log(`Found string: ${string}`); // prints 'original esm string' |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.