11cb0ef41Sopenharmony_ciimport { spawnPromisified } from '../common/index.mjs';
21cb0ef41Sopenharmony_ciimport * as fixtures from '../common/fixtures.mjs';
31cb0ef41Sopenharmony_ciimport assert from 'node:assert';
41cb0ef41Sopenharmony_ciimport { execPath } from 'node:process';
51cb0ef41Sopenharmony_ciimport { describe, it } from 'node:test';
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_cidescribe('ESM: nonexistent loader', () => {
91cb0ef41Sopenharmony_ci  it('should throw', async () => {
101cb0ef41Sopenharmony_ci    const { code, stderr } = await spawnPromisified(execPath, [
111cb0ef41Sopenharmony_ci      '--experimental-loader',
121cb0ef41Sopenharmony_ci      'i-dont-exist',
131cb0ef41Sopenharmony_ci      fixtures.path('print-error-message.js'),
141cb0ef41Sopenharmony_ci    ]);
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci    assert.notStrictEqual(code, 0);
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci    // Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist' imported from
191cb0ef41Sopenharmony_ci    assert.match(stderr, /ERR_MODULE_NOT_FOUND/);
201cb0ef41Sopenharmony_ci    assert.match(stderr, /'i-dont-exist'/);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci    assert.ok(!stderr.includes('Bad command or file name'));
231cb0ef41Sopenharmony_ci  });
241cb0ef41Sopenharmony_ci});
25