mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
8c5c2c18b6
This reverts commit 22cb99d073
.
PR-URL: https://github.com/nodejs/node/pull/53183
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import '../common/index.mjs';
|
|
import assert from 'node:assert/strict';
|
|
import { mock } from '../fixtures/es-module-loaders/mock.mjs';
|
|
|
|
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'
|
|
}));
|