diff --git a/test/es-module/test-esm-local-deprecations.mjs b/test/es-module/test-esm-local-deprecations.mjs index 5a6638d1d90e5a..d9d86fefc06464 100644 --- a/test/es-module/test-esm-local-deprecations.mjs +++ b/test/es-module/test-esm-local-deprecations.mjs @@ -1,4 +1,4 @@ -import { mustCall } from '../common/index.mjs'; +import '../common/index.mjs'; import assert from 'assert'; import fixtures from '../common/fixtures.js'; import { pathToFileURL } from 'url'; @@ -9,15 +9,20 @@ const selfDeprecatedFolders = const deprecatedFoldersIgnore = fixtures.path('/es-modules/deprecated-folders-ignore/main.js'); -let curWarning = 0; const expectedWarnings = [ '"./" in the "exports" field', '"#self/" in the "imports" field' ]; -process.addListener('warning', mustCall((warning) => { - assert(warning.stack.includes(expectedWarnings[curWarning++]), warning.stack); -}, expectedWarnings.length)); +process.addListener('warning', (warning) => { + if (warning.stack.includes(expectedWarnings[0])) { + expectedWarnings.shift(); + } +}); + +process.on('exit', () => { + assert.deepStrictEqual(expectedWarnings, []); +}); (async () => { await import(pathToFileURL(selfDeprecatedFolders));