Skip to content

Commit

Permalink
test: account for pending deprecations in esm test
Browse files Browse the repository at this point in the history
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: #37542
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and targos committed Mar 2, 2021
1 parent d93137b commit 00b3446
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/es-module/test-esm-local-deprecations.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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));
Expand Down

0 comments on commit 00b3446

Please sign in to comment.