Skip to content

Commit 9cd5c0e

Browse files
committed
test: add test for missing dynamic instantiate hook
PR-URL: #21506 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
1 parent e25b102 commit 9cd5c0e

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Flags: --experimental-modules --loader ./test/fixtures/es-module-loaders/missing-dynamic-instantiate-hook.mjs
2+
3+
import{
4+
crashOnUnhandledRejection,
5+
expectsError
6+
}from'../common';
7+
8+
crashOnUnhandledRejection();
9+
10+
import('test').catch(expectsError({
11+
code: 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
12+
message: 'The ES Module loader may not return a format of \'dynamic\' '+
13+
'when no dynamicInstantiate function was provided'
14+
}));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exportfunctionresolve(specifier,parentModule,defaultResolver){
2+
if(specifier!=='test'){
3+
returndefaultResolver(specifier,parentModule);
4+
}
5+
return{url: 'file://',format: 'dynamic'};
6+
}

0 commit comments

Comments
 (0)