0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/es-module/test-esm-loader-not-found.mjs
Jacob Smith 447635b440
test: refactor ESM tests to improve performance
PR-URL: https://github.com/nodejs/node/pull/43784
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-07-29 10:42:55 +02:00

25 lines
768 B
JavaScript

import { spawnPromisified } from '../common/index.mjs';
import * as fixtures from '../common/fixtures.mjs';
import assert from 'node:assert';
import { execPath } from 'node:process';
import { describe, it } from 'node:test';
describe('ESM: nonexistent loader', () => {
it('should throw', async () => {
const { code, stderr } = await spawnPromisified(execPath, [
'--experimental-loader',
'i-dont-exist',
fixtures.path('print-error-message.js'),
]);
assert.notStrictEqual(code, 0);
// Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'i-dont-exist' imported from
assert.match(stderr, /ERR_MODULE_NOT_FOUND/);
assert.match(stderr, /'i-dont-exist'/);
assert.ok(!stderr.includes('Bad command or file name'));
});
});