diff options
author | Rich Trott <rtrott@gmail.com> | 2021-02-27 22:46:11 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-03-02 16:08:53 +0300 |
commit | 00b3446a8ebeab603f87639588c42f4ec44a8546 (patch) | |
tree | 961dae2ccaabe325876a8e4d02300b94d1e35181 /test | |
parent | d93137b2a9e215f8715bfab39d04525da4b0842c (diff) |
test: account for pending deprecations in esm test
test-esm-local-deprecations fails if NODE_PENDING_DEPRECATION is set
because the test expects exactly the warnings it expects and no other
warnings. Modify the test to still expect its errors in the order it
expects them, but to ignore errors it does not expect.
PR-URL: https://github.com/nodejs/node/pull/37542
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/es-module/test-esm-local-deprecations.mjs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/es-module/test-esm-local-deprecations.mjs b/test/es-module/test-esm-local-deprecations.mjs index 5a6638d1d90..d9d86fefc06 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)); |