diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-06-24 16:56:00 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-07-03 17:30:22 +0200 |
commit | 908518d9e348581c72a6302ed1bf518b57d5ae0b (patch) | |
tree | 55a58763131424991742cff1da5f1df33abe9415 | |
parent | f85962fe4d3afa55aedcfdab3aa61258c5af3e2a (diff) | |
download | node-new-908518d9e348581c72a6302ed1bf518b57d5ae0b.tar.gz |
test: add test for missing dynamic instantiate hook
PR-URL: https://github.com/nodejs/node/pull/21506
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
-rw-r--r-- | test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs | 14 | ||||
-rw-r--r-- | test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs | 6 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs new file mode 100644 index 0000000000..27447b3e43 --- /dev/null +++ b/test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs @@ -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' +})); diff --git a/test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs b/test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs new file mode 100644 index 0000000000..6993747fcc --- /dev/null +++ b/test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs @@ -0,0 +1,6 @@ +export function resolve(specifier, parentModule, defaultResolver) { + if (specifier !== 'test') { + return defaultResolver(specifier, parentModule); + } + return { url: 'file://', format: 'dynamic' }; +} |