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

Function testNoCallback

test/parallel/test-vm-module-dynamic-import.js:10–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8const { Script, SourceTextModule } = require('vm');
9
10async function testNoCallback() {
11 const m = new SourceTextModule(`
12 globalThis.importResult = import("foo");
13 globalThis.importResult.catch(() => {});
14 `);
15 await m.link(common.mustNotCall());
16 await m.evaluate();
17 let threw = false;
18 try {
19 await globalThis.importResult;
20 } catch (err) {
21 threw = true;
22 assert.strictEqual(err.code, 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING');
23 }
24 delete globalThis.importResult;
25 assert(threw);
26}
27
28async function test() {
29 const foo = new SourceTextModule('export const a = 1;');

Calls 3

assertFunction · 0.50
linkMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…