node/test/fixtures/test-runner/coverage-file-name/test.js
Heath Dutton🕴️ a00f5fea70
test_runner: fix coverage report when a directory is named file
The coverage tree traversal checked `tree[key].file` to detect file
entries. When a directory named "file" contained a file also named
"file", this check incorrectly matched the child entry instead of
file metadata, causing a TypeError when accessing `.path`.

Check for `.file?.path` instead to correctly identify file metadata.

Fixes: https://github.com/nodejs/node/issues/61080
PR-URL: https://github.com/nodejs/node/pull/61169
Reviewed-By: Aviv Keller <me@aviv.sh>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2026-01-17 17:34:06 +00:00

7 lines
161 B
JavaScript

'use strict';
const { fn } = require('./file/file');
const test = require('node:test');
test('coverage with file/file directory structure', () => {
fn();
});