2022-07-29 08:42:55 +00:00
|
|
|
import { spawnPromisified } from '../common/index.mjs';
|
2022-03-28 21:43:15 +00:00
|
|
|
import { fileURL } from '../common/fixtures.mjs';
|
2022-07-29 08:42:55 +00:00
|
|
|
import { doesNotMatch, match, strictEqual } from 'node:assert';
|
|
|
|
import { execPath } from 'node:process';
|
|
|
|
import { describe, it } from 'node:test';
|
2022-03-28 21:43:15 +00:00
|
|
|
|
2022-05-04 15:51:12 +00:00
|
|
|
|
2024-03-23 21:11:28 +00:00
|
|
|
describe('ESM: warn for obsolete hooks provided', { concurrency: !process.env.TEST_PARALLEL }, () => {
|
2022-07-29 08:42:55 +00:00
|
|
|
it('should not print warnings when no experimental features are enabled or used', async () => {
|
|
|
|
const { code, signal, stderr } = await spawnPromisified(execPath, [
|
|
|
|
'--input-type=module',
|
|
|
|
'--eval',
|
|
|
|
`import ${JSON.stringify(fileURL('es-module-loaders', 'module-named-exports.mjs'))}`,
|
|
|
|
]);
|
|
|
|
|
2022-05-04 15:51:12 +00:00
|
|
|
doesNotMatch(
|
|
|
|
stderr,
|
|
|
|
/ExperimentalWarning/,
|
|
|
|
new Error('No experimental warning(s) should be emitted when no experimental feature is enabled')
|
|
|
|
);
|
2022-03-28 21:43:15 +00:00
|
|
|
strictEqual(code, 0);
|
|
|
|
strictEqual(signal, null);
|
2022-07-29 08:42:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('experimental warnings for enabled experimental feature', () => {
|
|
|
|
for (
|
2023-09-19 03:59:50 +00:00
|
|
|
const [experiment, ...args] of [
|
|
|
|
[
|
|
|
|
/`--experimental-loader` may be removed in the future/,
|
|
|
|
'--experimental-loader',
|
|
|
|
fileURL('es-module-loaders', 'hooks-custom.mjs'),
|
|
|
|
],
|
2022-07-29 08:42:55 +00:00
|
|
|
]
|
|
|
|
) {
|
|
|
|
it(`should print for ${experiment.toString().replaceAll('/', '')}`, async () => {
|
|
|
|
const { code, signal, stderr } = await spawnPromisified(execPath, [
|
2023-09-19 03:59:50 +00:00
|
|
|
...args,
|
2022-07-29 08:42:55 +00:00
|
|
|
'--input-type=module',
|
|
|
|
'--eval',
|
|
|
|
`import ${JSON.stringify(fileURL('es-module-loaders', 'module-named-exports.mjs'))}`,
|
|
|
|
]);
|
|
|
|
|
|
|
|
match(stderr, /ExperimentalWarning/);
|
|
|
|
match(stderr, experiment);
|
|
|
|
strictEqual(code, 0);
|
|
|
|
strictEqual(signal, null);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|