forked from nodejs/node
/
test-esm-local-deprecations.mjs
39 lines (31 loc) · 1.09 KB
/
test-esm-local-deprecations.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Flags: --pending-deprecation
import '../common/index.mjs';
import assert from 'assert';
import fixtures from '../common/fixtures.js';
import { pathToFileURL } from 'url';
const selfDeprecatedFolders =
fixtures.path('/es-modules/self-deprecated-folders/main.js');
const deprecatedFoldersIgnore =
fixtures.path('/es-modules/deprecated-folders-ignore/main.js');
const deprecatedTrailingSlashPattern =
fixtures.path('/es-modules/pattern-trailing-slash.mjs');
const expectedWarnings = [
'"./" in the "exports" field',
'"#self/" in the "imports" field',
'"./folder/" in the "exports" field',
'"./trailing-pattern-slash/" in the "exports" field',
];
process.addListener('warning', (warning) => {
if (warning.stack.includes(expectedWarnings[0])) {
expectedWarnings.shift();
}
});
process.on('exit', () => {
assert.deepStrictEqual(expectedWarnings, []);
});
(async () => {
await import(pathToFileURL(selfDeprecatedFolders));
await import(pathToFileURL(deprecatedFoldersIgnore));
await import(pathToFileURL(deprecatedTrailingSlashPattern));
})()
.catch((err) => console.error(err));