From 00b3446a8ebeab603f87639588c42f4ec44a8546 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 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell --- 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));