node/test/fixtures/v8-coverage/combined_coverage/third.test.js
cjihrig 4360389d67
test_runner: omit inaccessible files from coverage
If V8 generates code coverage for a file that is later
inaccessible to the test runner, then omit that file from the
coverage report.

PR-URL: https://github.com/nodejs/node/pull/47850
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
2023-05-10 14:08:00 +00:00

25 lines
664 B
JavaScript

'use strict';
const assert = require('node:assert');
const { unlinkSync, writeFileSync } = require('node:fs')
const { join } = require('node:path');
const { test } = require('node:test');
const common = require('./common');
test('third 1', () => {
common.fnC(1, 4);
common.fnD(99);
});
assert(process.env.NODE_TEST_TMPDIR);
const tmpFilePath = join(process.env.NODE_TEST_TMPDIR, 'temp-module.js');
writeFileSync(tmpFilePath, `
module.exports = {
fn() {
return 42;
}
};
`);
const tempModule = require(tmpFilePath);
assert.strictEqual(tempModule.fn(), 42);
// Deleted files should not be part of the coverage report.
unlinkSync(tmpFilePath);