1'use strict'; 2 3const common = require('../common'); 4const { Script, compileFunction } = require('vm'); 5const assert = require('assert'); 6 7assert.rejects(async () => { 8 const script = new Script('import("fs")'); 9 const imported = script.runInThisContext(); 10 await imported; 11}, { 12 code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING' 13}).then(common.mustCall()); 14 15assert.rejects(async () => { 16 const imported = compileFunction('return import("fs")')(); 17 await imported; 18}, { 19 code: 'ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING' 20}).then(common.mustCall()); 21