mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: fix es-module/test-esm-initialization
PR-URL: https://github.com/nodejs/node/pull/48880 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
f3d62abb19
commit
314bd6095c
1 file changed
+5
-4
@@ -8,22 +8,23 @@ import { describe, it } from 'node:test';
|
||||
describe('ESM: ensure initialization happens only once', { concurrency: true }, () => {
|
||||
it(async () => {
|
||||
const { code, stderr, stdout } = await spawnPromisified(execPath, [
|
||||
'--experimental-import-meta-resolve',
|
||||
'--loader',
|
||||
fixtures.fileURL('es-module-loaders', 'loader-resolve-passthru.mjs'),
|
||||
'--no-warnings',
|
||||
fixtures.path('es-modules', 'runmain.mjs'),
|
||||
]);
|
||||
|
||||
// Length minus 1 because the first match is the needle.
|
||||
const resolveHookRunCount = (stdout.match(/resolve passthru/g)?.length ?? 0) - 1;
|
||||
|
||||
assert.strictEqual(stderr, '');
|
||||
/**
|
||||
* resolveHookRunCount = 2:
|
||||
* 1. fixtures/…/runmain.mjs
|
||||
* 2. node:module (imported by fixtures/…/runmain.mjs)
|
||||
* 3. doesnt-matter.mjs (first import.meta.resolve call)
|
||||
* 4. fixtures/…/runmain.mjs (entry point)
|
||||
* 5. doesnt-matter.mjs (second import.meta.resolve call)
|
||||
*/
|
||||
assert.strictEqual(resolveHookRunCount, 2);
|
||||
assert.strictEqual(stdout.match(/resolve passthru/g)?.length, 5);
|
||||
assert.strictEqual(code, 0);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user