Skip to content

Commit

Permalink
Test for missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyBooth committed Jun 25, 2024
1 parent 2082b0e commit 266c499
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/es-module/test-esm-detect-ambiguous.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,25 @@ describe('--experimental-detect-module', { concurrency: !process.env.TEST_PARALL
strictEqual(code, 0);
strictEqual(signal, null);
});

it('should throw the usual error for a missing file', async () => {
const { code, signal, stdout, stderr } = await spawnPromisified(process.execPath, [
'--no-warnings',
'--experimental-detect-module',
'--import',
`data:text/javascript,${encodeURIComponent(
'import { register } from "node:module";' +
'import { pathToFileURL } from "node:url";' +
'register("./transpile-esm-to-cjs.mjs", pathToFileURL("./"));'
)}`,
fixtures.path('es-modules/package-without-type/imports-nonexistent.js'),
], { cwd: fixtures.fileURL('es-module-loaders/') });

match(stderr, /ERR_MODULE_NOT_FOUND.+does-not-exist\.js/);
strictEqual(stdout, 'Resolved format: module\nLoaded original format: module\n');
strictEqual(code, 1);
strictEqual(signal, null);
});
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./does-not-exist.js";

0 comments on commit 266c499

Please sign in to comment.