Skip to content

Commit 314bd60

Browse files
aduh95RafaelGSS
authored andcommitted
test: fix es-module/test-esm-initialization
PR-URL: #48880 Reviewed-By: Luigi Pinca <[email protected]>
1 parent f3d62ab commit 314bd60

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

test/es-module/test-esm-initialization.mjs

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,23 @@ import { describe, it } from 'node:test';
88
describe('ESM: ensure initialization happens only once', { concurrency: true }, () => {
99
it(async () => {
1010
const { code, stderr, stdout } = await spawnPromisified(execPath, [
11+
'--experimental-import-meta-resolve',
1112
'--loader',
1213
fixtures.fileURL('es-module-loaders', 'loader-resolve-passthru.mjs'),
1314
'--no-warnings',
1415
fixtures.path('es-modules', 'runmain.mjs'),
1516
]);
1617

17-
// Length minus 1 because the first match is the needle.
18-
const resolveHookRunCount = (stdout.match(/resolve passthru/g)?.length ?? 0) - 1;
19-
2018
assert.strictEqual(stderr, '');
2119
/**
2220
* resolveHookRunCount = 2:
2321
* 1. fixtures/…/runmain.mjs
2422
* 2. node:module (imported by fixtures/…/runmain.mjs)
23+
* 3. doesnt-matter.mjs (first import.meta.resolve call)
24+
* 4. fixtures/…/runmain.mjs (entry point)
25+
* 5. doesnt-matter.mjs (second import.meta.resolve call)
2526
*/
26-
assert.strictEqual(resolveHookRunCount, 2);
27+
assert.strictEqual(stdout.match(/resolve passthru/g)?.length, 5);
2728
assert.strictEqual(code, 0);
2829
});
2930
});

0 commit comments

Comments
 (0)