Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions test/parallel/test-vm-module-dynamic-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,34 @@ async function testInvalid() {
await result.catch(common.mustCall((e) => {
assert.strictEqual(e.code, 'ERR_VM_MODULE_NOT_MODULE');
}));

const s = new Script('import("foo")', {
importModuleDynamically: common.mustCall((specifier, wrap) => {
return undefined;
}),
});
let threw = false;
try {
await s.runInThisContext();
} catch (e) {
threw = true;
assert.strictEqual(e.code, 'ERR_VM_MODULE_NOT_MODULE');
}
assert(threw);
}

async function testInvalidimportModuleDynamically() {
assert.throws(
() => new Script(
'import("foo")',
{ importModuleDynamically: false }),
{ code: 'ERR_INVALID_ARG_TYPE' }
);
}

const done = common.mustCallAtLeast(3);
(async function() {
await testNoCallback();
done();

await test();
done();

await testInvalid();
done();
await testInvalidimportModuleDynamically();
}()).then(common.mustCall());