Skip to content

Commit f02637e

Browse files
aduh95targos
authored andcommitted
test: fix es-module/test-esm-initialization
PR-URL: #48880 Backport-PR-URL: #50669 Reviewed-By: Luigi Pinca <[email protected]>
1 parent 14e148e commit f02637e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
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 }=awaitspawnPromisified(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-
constresolveHookRunCount=(stdout.match(/resolvepassthru/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(/resolvepassthru/g)?.length,5);
2728
assert.strictEqual(code,0);
2829
});
2930
});

0 commit comments

Comments
(0)