node/test/parallel/test-module-cache.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

19 lines
454 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const filePath = tmpdir.resolve('test-module-cache.json');
assert.throws(
() => require(filePath),
{ code: 'MODULE_NOT_FOUND' }
);
fs.writeFileSync(filePath, '[]');
const content = require(filePath);
assert.strictEqual(Array.isArray(content), true);
assert.strictEqual(content.length, 0);