Skip to content

Commit 266c499

Browse files
committed
Test for missing file
1 parent 2082b0e commit 266c499

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

test/es-module/test-esm-detect-ambiguous.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,25 @@ describe('--experimental-detect-module', { concurrency: !process.env.TEST_PARALL
424424
strictEqual(code, 0);
425425
strictEqual(signal, null);
426426
});
427+
428+
it('should throw the usual error for a missing file', async () => {
429+
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
430+
'--no-warnings',
431+
'--experimental-detect-module',
432+
'--import',
433+
`data:text/javascript,${encodeURIComponent(
434+
'import { register } from "node:module";' +
435+
'import { pathToFileURL } from "node:url";' +
436+
'register("./transpile-esm-to-cjs.mjs", pathToFileURL("./"));'
437+
)}`,
438+
fixtures.path('es-modules/package-without-type/imports-nonexistent.js'),
439+
], { cwd: fixtures.fileURL('es-module-loaders/') });
440+
441+
match(stderr, /ERR_MODULE_NOT_FOUND.+does-not-exist\.js/);
442+
strictEqual(stdout, 'Resolved format: module\nLoaded original format: module\n');
443+
strictEqual(code, 1);
444+
strictEqual(signal, null);
445+
});
427446
});
428447
});
429448

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./does-not-exist.js";

0 commit comments

Comments
 (0)