Skip to content

Commit 00b3446

Browse files
Trotttargos
authored andcommitted
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: #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>
1 parent d93137b commit 00b3446

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

test/es-module/test-esm-local-deprecations.mjs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mustCall } from '../common/index.mjs';
1+
import '../common/index.mjs';
22
import assert from 'assert';
33
import fixtures from '../common/fixtures.js';
44
import { pathToFileURL } from 'url';
@@ -9,15 +9,20 @@ const selfDeprecatedFolders =
99
const deprecatedFoldersIgnore =
1010
fixtures.path('/es-modules/deprecated-folders-ignore/main.js');
1111

12-
let curWarning = 0;
1312
const expectedWarnings = [
1413
'"./" in the "exports" field',
1514
'"#self/" in the "imports" field'
1615
];
1716

18-
process.addListener('warning', mustCall((warning) => {
19-
assert(warning.stack.includes(expectedWarnings[curWarning++]), warning.stack);
20-
}, expectedWarnings.length));
17+
process.addListener('warning', (warning) => {
18+
if (warning.stack.includes(expectedWarnings[0])) {
19+
expectedWarnings.shift();
20+
}
21+
});
22+
23+
process.on('exit', () => {
24+
assert.deepStrictEqual(expectedWarnings, []);
25+
});
2126

2227
(async () => {
2328
await import(pathToFileURL(selfDeprecatedFolders));

0 commit comments

Comments
 (0)