Skip to content

Commit

Permalink
test: esm loader unknown builtin module
Browse files Browse the repository at this point in the history
PR-URL: #24183
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
franher authored and gireeshpunathil committed Nov 12, 2018
1 parent e39aba1 commit 0229e37
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export async function resolve(specifier, parent, defaultResolve) {
if (specifier === 'unknown-builtin-module') {
return { url: 'unknown-builtin-module', format: 'builtin' };
}
return defaultResolve(specifier, parent);
}
12 changes: 12 additions & 0 deletions test/parallel/test-loaders-unknown-builtin-module.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs
import { expectsError, mustCall } from '../common';
import assert from 'assert';

const unknownBuiltinModule = 'unknown-builtin-module';

import(unknownBuiltinModule)
.then(assert.fail, expectsError({
code: 'ERR_UNKNOWN_BUILTIN_MODULE',
message: `No such built-in module: ${unknownBuiltinModule}`
}))
.then(mustCall());

0 comments on commit 0229e37

Please sign in to comment.