Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/test_runner/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ function getCoverageReport(pad, summary, symbol, color, table) {
if (color) {
filePadLength += 2;
}
filePadLength = MathMax(filePadLength, 'file'.length);
filePadLength = MathMax(filePadLength, 'all files'.length);
if (filePadLength > (process.stdout.columns / 2)) {
filePadLength = MathFloor(process.stdout.columns / 2);
}
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/test-runner/output/coverage-short-filename.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Flags: --experimental-test-coverage
// here we can't import common module as the coverage will be different based on the system
// Unused imports are here in order to populate the coverage report
// eslint-disable-next-line no-unused-vars
import * as a from '../coverage-snap/a.js';

import { test } from 'node:test';

test(`Coverage Print Short Filename`);
25 changes: 25 additions & 0 deletions test/fixtures/test-runner/output/coverage-short-filename.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
TAP version 13
# Subtest: Coverage Print Short Filename
ok 1 - Coverage Print Short Filename
---
duration_ms: *
type: 'test'
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# ---------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# ---------------------------------------------------------------------------------------
# a.js | 55.77 | 100.00 | 0.00 | 5-7 9-11 13-15 17-19 29-30 40-42 45-47 50-52
# ---------------------------------------------------------------------------------------
# all files | 55.77 | 100.00 | 0.00 |
# ---------------------------------------------------------------------------------------
# end of coverage report
9 changes: 7 additions & 2 deletions test/parallel/test-runner-output.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,17 @@ const tests = [
name: 'test-runner/output/coverage-width-infinity-uncovered-lines.mjs',
flags: ['--test-reporter=tap', '--test-coverage-exclude=!test/**'],
} : false,
process.features.inspector ? {
name: 'test-runner/output/coverage-short-filename.mjs',
flags: ['--test-reporter=tap', '--test-coverage-exclude=../output/**'],
cwd: fixtures.path('test-runner/coverage-snap'),
} : false,
]
.filter(Boolean)
.map(({ flags, name, tty, transform }) => ({
.map(({ flags, name, tty, transform, cwd }) => ({
name,
fn: common.mustCall(async () => {
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags });
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform, { tty, flags, cwd });
}),
}));

Expand Down
Loading