From 314bd6095c6eea045ea2e01a8272b51fff7115b1 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 29 Jul 2023 11:51:10 +0200 Subject: [PATCH] test: fix `es-module/test-esm-initialization` PR-URL: https://github.com/nodejs/node/pull/48880 Reviewed-By: Luigi Pinca --- test/es-module/test-esm-initialization.mjs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/es-module/test-esm-initialization.mjs b/test/es-module/test-esm-initialization.mjs index aa946a50152d40..f03a47d5d3791a 100644 --- a/test/es-module/test-esm-initialization.mjs +++ b/test/es-module/test-esm-initialization.mjs @@ -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); }); });