forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: esm loader unknown builtin module
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
1 parent
bd43ef8
commit cdcafc1
Showing
2 changed files
with
18 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
test/fixtures/es-module-loaders/loader-unknown-builtin-module.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |