11cb0ef41Sopenharmony_ciimport { spawnPromisified } from '../common/index.mjs';
21cb0ef41Sopenharmony_ciimport { fileURL } from '../common/fixtures.mjs';
31cb0ef41Sopenharmony_ciimport { doesNotMatch, match, strictEqual } from 'node:assert';
41cb0ef41Sopenharmony_ciimport { execPath } from 'node:process';
51cb0ef41Sopenharmony_ciimport { describe, it } from 'node:test';
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cidescribe('ESM: warn for obsolete hooks provided', { concurrency: true }, () => {
91cb0ef41Sopenharmony_ci  it('should not print warnings when no experimental features are enabled or used', async () => {
101cb0ef41Sopenharmony_ci    const { code, signal, stderr } = await spawnPromisified(execPath, [
111cb0ef41Sopenharmony_ci      '--input-type=module',
121cb0ef41Sopenharmony_ci      '--eval',
131cb0ef41Sopenharmony_ci      `import ${JSON.stringify(fileURL('es-module-loaders', 'module-named-exports.mjs'))}`,
141cb0ef41Sopenharmony_ci    ]);
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci    doesNotMatch(
171cb0ef41Sopenharmony_ci      stderr,
181cb0ef41Sopenharmony_ci      /ExperimentalWarning/,
191cb0ef41Sopenharmony_ci      new Error('No experimental warning(s) should be emitted when no experimental feature is enabled')
201cb0ef41Sopenharmony_ci    );
211cb0ef41Sopenharmony_ci    strictEqual(code, 0);
221cb0ef41Sopenharmony_ci    strictEqual(signal, null);
231cb0ef41Sopenharmony_ci  });
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ci  describe('experimental warnings for enabled experimental feature', () => {
261cb0ef41Sopenharmony_ci    for (
271cb0ef41Sopenharmony_ci      const [experiment, ...args] of [
281cb0ef41Sopenharmony_ci        [
291cb0ef41Sopenharmony_ci          /`--experimental-loader` may be removed in the future/,
301cb0ef41Sopenharmony_ci          '--experimental-loader',
311cb0ef41Sopenharmony_ci          fileURL('es-module-loaders', 'hooks-custom.mjs'),
321cb0ef41Sopenharmony_ci        ],
331cb0ef41Sopenharmony_ci        [/Network Imports/, '--experimental-network-imports'],
341cb0ef41Sopenharmony_ci        [/specifier resolution/, '--experimental-specifier-resolution=node'],
351cb0ef41Sopenharmony_ci      ]
361cb0ef41Sopenharmony_ci    ) {
371cb0ef41Sopenharmony_ci      it(`should print for ${experiment.toString().replaceAll('/', '')}`, async () => {
381cb0ef41Sopenharmony_ci        const { code, signal, stderr } = await spawnPromisified(execPath, [
391cb0ef41Sopenharmony_ci          ...args,
401cb0ef41Sopenharmony_ci          '--input-type=module',
411cb0ef41Sopenharmony_ci          '--eval',
421cb0ef41Sopenharmony_ci          `import ${JSON.stringify(fileURL('es-module-loaders', 'module-named-exports.mjs'))}`,
431cb0ef41Sopenharmony_ci        ]);
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci        match(stderr, /ExperimentalWarning/);
461cb0ef41Sopenharmony_ci        match(stderr, experiment);
471cb0ef41Sopenharmony_ci        strictEqual(code, 0);
481cb0ef41Sopenharmony_ci        strictEqual(signal, null);
491cb0ef41Sopenharmony_ci      });
501cb0ef41Sopenharmony_ci    }
511cb0ef41Sopenharmony_ci  });
521cb0ef41Sopenharmony_ci});
53