()
| 38 | assert.strictEqual(typeof USE_MAIN_CONTEXT_DEFAULT_LOADER, 'symbol'); |
| 39 | |
| 40 | async function main() { |
| 41 | tmpdir.refresh(); |
| 42 | process.chdir(tmpdir.path); |
| 43 | |
| 44 | // |
| 45 | { |
| 46 | const options = { |
| 47 | importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, |
| 48 | }; |
| 49 | const ctx = createContext({}, options); |
| 50 | const s = new Script('Promise.resolve("import(\'./message.mjs\')").then(eval)', { |
| 51 | importModuleDynamically: common.mustNotCall(), |
| 52 | }); |
| 53 | await assert.rejects(s.runInContext(ctx), { code: 'ERR_MODULE_NOT_FOUND' }); |
| 54 | } |
| 55 | |
| 56 | const moduleUrl = fixtures.fileURL('es-modules', 'message.mjs'); |
| 57 | fs.copyFileSync(moduleUrl, tmpdir.resolve('message.mjs')); |
| 58 | { |
| 59 | const options = { |
| 60 | importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, |
| 61 | }; |
| 62 | const ctx = createContext({}, options); |
| 63 | const moduleUrl = fixtures.fileURL('es-modules', 'message.mjs'); |
| 64 | const namespace = await import(moduleUrl.href); |
| 65 | const script = new Script('Promise.resolve("import(\'./message.mjs\')").then(eval)', { |
| 66 | importModuleDynamically: common.mustNotCall(), |
| 67 | }); |
| 68 | const result = await script.runInContext(ctx); |
| 69 | assert.deepStrictEqual(result, namespace); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | main().then(common.mustCall()); |
no test coverage detected
searching dependent graphs…