Skip to content

Commit

Permalink
test: esm loader unknown builtin module
Browse files Browse the repository at this point in the history
PR-URL: nodejs#24183
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
franher authored and kiyomizumia committed Nov 15, 2018
1 parent bd43ef8 commit cdcafc1
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 cdcafc1

Please sign in to comment.