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>
This commit is contained in:
Rich Trott committed 2021-03-01 12:16:30 -08:00
1 parent 360e8c842a
commit 20bfa17cc8
1 file changed
+10 -5
+10 -5
View File
@@ -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));