11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst assert = require('node:assert'); 61cb0ef41Sopenharmony_ciconst fs = require('node:fs/promises'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_citmpdir.refresh(); 91cb0ef41Sopenharmony_ciconst target = tmpdir.fileURL(`${Math.random()}.mjs`); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci(async () => { 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci await assert.rejects(import(target), { code: 'ERR_MODULE_NOT_FOUND' }); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci await fs.writeFile(target, 'export default "actual target"\n'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci const moduleRecord = await import(target); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci await fs.rm(target); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci assert.strictEqual(await import(target), moduleRecord); 221cb0ef41Sopenharmony_ci})().then(common.mustCall()); 23