0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-require-enoent-dir.js
Livia Medeiros 966e3d3493
test: use tmpdir.resolve()
PR-URL: https://github.com/nodejs/node/pull/49128
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2023-08-15 13:45:44 +00:00

31 lines
722 B
JavaScript

'use strict';
const common = require('../common');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
tmpdir.refresh();
const fooPath = tmpdir.resolve('foo.cjs');
fs.writeFileSync(fooPath, '');
const dirPath = tmpdir.resolve('delete_me');
fs.mkdirSync(dirPath, {
recursive: true
});
const barPath = path.join(dirPath, 'bar.cjs');
fs.writeFileSync(barPath, `
module.exports = () => require('../foo.cjs').call()
`);
const foo = require(fooPath);
const unique = Symbol('unique');
foo.call = common.mustCall(() => unique);
const bar = require(barPath);
fs.rmSync(dirPath, { recursive: true });
assert.strict.equal(bar(), unique);