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>
This commit is contained in:
Michaël Zasso committed 2018-07-03 17:30:22 +02:00
1 parent f85962fe4d
commit 908518d9e3
2 files changed
+20

No files matched your search

@@ -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'
}));
@@ -0,0 +1,6 @@
export function resolve(specifier, parentModule, defaultResolver) {
if (specifier !== 'test') {
return defaultResolver(specifier, parentModule);
}
return { url: 'file://', format: 'dynamic' };
}