From 543142f064562263ef0620241ca8abddd9888aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 24 Jun 2018 16:56:00 +0200 Subject: [PATCH] test: add test for missing dynamic instantiate hook --- ...esm-loader-missing-dynamic-instantiate-hook.mjs | 14 ++++++++++++++ .../missing-dynamic-instantiate-hook.mjs | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 test/es-module/test-esm-loader-missing-dynamic-instantiate-hook.mjs create mode 100644 test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs 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 00000000000000..27447b3e436afe --- /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 00000000000000..6993747fcc0142 --- /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' }; +}