summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-06-24 16:56:00 +0200
committerMichaël Zasso <targos@protonmail.com>2018-07-03 17:30:22 +0200
commit908518d9e348581c72a6302ed1bf518b57d5ae0b (patch)
tree55a58763131424991742cff1da5f1df33abe9415 /test
parentf85962fe4d3afa55aedcfdab3aa61258c5af3e2a (diff)
downloadandroid-node-v8-908518d9e348581c72a6302ed1bf518b57d5ae0b.tar.gz
android-node-v8-908518d9e348581c72a6302ed1bf518b57d5ae0b.tar.bz2
android-node-v8-908518d9e348581c72a6302ed1bf518b57d5ae0b.zip
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>
Diffstat (limited to 'test')
-rw-r--r--test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs14
-rw-r--r--test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs6
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' };
+}