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

Function testInvalid

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

Source from the content-addressed store, hash-verified

74}
75
76async function testInvalid() {
77 const m = new SourceTextModule('globalThis.fooResult = import("foo")', {
78 importModuleDynamically: common.mustCall((specifier, wrap) => {
79 return 5;
80 }),
81 });
82 await m.link(common.mustNotCall());
83 await m.evaluate();
84 await globalThis.fooResult.catch(common.mustCall((e) => {
85 assert.strictEqual(e.code, 'ERR_VM_MODULE_NOT_MODULE');
86 }));
87 delete globalThis.fooResult;
88
89 const s = new Script('import("bar")', {
90 importModuleDynamically: common.mustCall((specifier, wrap) => {
91 return undefined;
92 }),
93 });
94 let threw = false;
95 try {
96 await s.runInThisContext();
97 } catch (e) {
98 threw = true;
99 assert.strictEqual(e.code, 'ERR_VM_MODULE_NOT_MODULE');
100 }
101 assert(threw);
102}
103
104async function testInvalidimportModuleDynamically() {
105 assert.throws(

Calls 4

runInThisContextMethod · 0.95
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…