Skip to content

Commit

Permalink
test: fix es-module/test-esm-initialization
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node#48880
Backport-PR-URL: nodejs/node#50669
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
sercher committed Apr 25, 2024
1 parent 8ef0291 commit 8f3e568
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions graal-nodejs/test/es-module/test-esm-initialization.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 8f3e568

Please sign in to comment.