-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esm: add back
globalPreload
tests and fix failing ones
PR-URL: #48779 Fixes: #48778 Fixes: #48516 Refs: #46402 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Jacob Smith <jacob@frende.me>
- Loading branch information
Showing
7 changed files
with
475 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,45 @@ | ||
// Flags: --loader ./test/fixtures/es-module-loaders/mock-loader.mjs | ||
import '../common/index.mjs'; | ||
import assert from 'assert/strict'; | ||
|
||
// This is provided by test/fixtures/es-module-loaders/mock-loader.mjs | ||
import mock from 'node:mock'; | ||
|
||
mock('node:events', { | ||
EventEmitter: 'This is mocked!' | ||
}); | ||
|
||
// This resolves to node:events | ||
// It is intercepted by mock-loader and doesn't return the normal value | ||
assert.deepStrictEqual(await import('events'), Object.defineProperty({ | ||
__proto__: null, | ||
EventEmitter: 'This is mocked!' | ||
}, Symbol.toStringTag, { | ||
enumerable: false, | ||
value: 'Module' | ||
})); | ||
|
||
const mutator = mock('node:events', { | ||
EventEmitter: 'This is mocked v2!' | ||
}); | ||
|
||
// It is intercepted by mock-loader and doesn't return the normal value. | ||
// This is resolved separately from the import above since the specifiers | ||
// are different. | ||
const mockedV2 = await import('node:events'); | ||
assert.deepStrictEqual(mockedV2, Object.defineProperty({ | ||
__proto__: null, | ||
EventEmitter: 'This is mocked v2!' | ||
}, Symbol.toStringTag, { | ||
enumerable: false, | ||
value: 'Module' | ||
})); | ||
|
||
mutator.EventEmitter = 'This is mocked v3!'; | ||
assert.deepStrictEqual(mockedV2, Object.defineProperty({ | ||
__proto__: null, | ||
EventEmitter: 'This is mocked v3!' | ||
}, Symbol.toStringTag, { | ||
enumerable: false, | ||
value: 'Module' | ||
})); |
Oops, something went wrong.