0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/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);