mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
eeddbfae6c
PR-URL: https://github.com/nodejs/node/pull/49138 Refs: https://github.com/nodejs/node/pull/49040 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
23 lines
566 B
JavaScript
23 lines
566 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
|
|
const assert = require('node:assert');
|
|
const fs = require('node:fs/promises');
|
|
|
|
tmpdir.refresh();
|
|
const target = tmpdir.fileURL(`${Math.random()}.mjs`);
|
|
|
|
(async () => {
|
|
|
|
await assert.rejects(import(target), { code: 'ERR_MODULE_NOT_FOUND' });
|
|
|
|
await fs.writeFile(target, 'export default "actual target"\n');
|
|
|
|
const moduleRecord = await import(target);
|
|
|
|
await fs.rm(target);
|
|
|
|
assert.strictEqual(await import(target), moduleRecord);
|
|
})().then(common.mustCall());
|