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 2018-06-24 16:56:00 +02:00
parent f85962fe4d
commit 908518d9e3
No known key found for this signature in database
GPG Key ID: 770F7A9A5AE15600
2 changed files with 20 additions and 0 deletions

View File

@ -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'
}));

View File

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