-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for missing dynamic instantiate hook
PR-URL: #21506 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.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,14 @@ | ||
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs | ||
|
||
import { | ||
crashOnUnhandledRejection, | ||
expectsError | ||
} from '../common'; | ||
|
||
crashOnUnhandledRejection(); | ||
|
||
import('test').catch(expectsError({ | ||
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK', | ||
message: 'The ES Module loader may not return a format of \'dynamic\' ' + | ||
'when no dynamicInstantiate function was provided' | ||
})); |
6 changes: 6 additions & 0 deletions
6
test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.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 function resolve(specifier, parentModule, defaultResolver) { | ||
if (specifier !== 'test') { | ||
return defaultResolver(specifier, parentModule); | ||
} | ||
return { url: 'file://', format: 'dynamic' }; | ||
} |