From e075f9655c512cf154ca7cb6caf6e8ef49b5d92a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 27 Feb 2021 11:46:11 -0800 Subject: [PATCH] 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. --- test/es-module/test-esm-local-deprecations.mjs | 15 ++++++++++----- 1 file 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 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));