MCPcopy Index your code
hub / github.com/nodejs/node / testMissing

Function testMissing

test/parallel/test-vm-module-referrer-realm.mjs:51–77  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49}
50
51async function testMissing() {
52 const ctx = createContext({});
53 {
54 const s = new Script('Promise.resolve("import(\'foo\')").then(eval)', {
55 importModuleDynamically: common.mustNotCall(),
56 });
57
58 const result = s.runInContext(ctx);
59 await assert.rejects(result, {
60 code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING',
61 });
62 }
63
64 {
65 const m = new SourceTextModule('globalThis.fooResult = Promise.resolve("import(\'foo\')").then(eval)', {
66 context: ctx,
67 importModuleDynamically: common.mustNotCall(),
68 });
69 await m.link(common.mustNotCall());
70 await m.evaluate();
71
72 await assert.rejects(ctx.fooResult, {
73 code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING',
74 });
75 delete ctx.fooResult;
76 }
77}
78
79await Promise.all([
80 test(),

Calls 4

runInContextMethod · 0.95
createContextFunction · 0.85
linkMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected