-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: refactor coverage report output for readability #47791
test_runner: refactor coverage report output for readability #47791
Conversation
Review requested:
|
lib/internal/test_runner/utils.js
Outdated
} | ||
return coverage; | ||
function addTableLine(prefix, width) { | ||
return `${prefix}${'-'.repeat(width)}\n`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return `${prefix}${'-'.repeat(width)}\n`; | |
return `${prefix}${StringPrototypeRepeat('-', width)}\n`; |
also consider memoizing, like https://github.com/nodejs/node/blob/102540aef9024ea6a8218a6d782243f1391612d2/lib/internal/test_runner/reporter/tap.js#L88-97
Thanks for this PR, it really improves the output of the coverage report. |
@MoLow Thanks! I have now implemented all your feedbacks. |
@dmnsgn are you planning to continue working on this? |
Conflicts all fixed as well. |
can you please squash this branch / omit the merge commit? |
Add a "table" parameter to getCoverageReport. Keep the tap coverage output intact. Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot. Group uncovered lines as ranges. Add yellow color for coverage between 50 and 90. Refs: nodejs#46674
… for truncate methods
c86191b
to
98a327b
Compare
@MoLow done, I rebased it. |
Landed in 23c7f65 |
function formatLinesToRanges(values) { | ||
return ArrayPrototypeMap(ArrayPrototypeReduce(values, (prev, current, index, array) => { | ||
if ((index > 0) && ((current - array[index - 1]) === 1)) { | ||
prev[prev.length - 1][1] = current; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use .at(-1)
?
if (truncate) result = truncate(result, width); | ||
if (color && coverage !== undefined) { | ||
if (coverage > 90) return `${coverageColors.high}${result}${color}`; | ||
if (coverage > 50) return `${coverageColors.medium}${result}${color}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if these values should be configurable someway...
I missed to publish my review before, anyway good to know this has landed :-) |
Add a "table" parameter to getCoverageReport. Keep the tap coverage output intact. Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot. Group uncovered lines as ranges. Add yellow color for coverage between 50 and 90. Refs: #46674 PR-URL: #47791 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Add a "table" parameter to getCoverageReport. Keep the tap coverage output intact. Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot. Group uncovered lines as ranges. Add yellow color for coverage between 50 and 90. Refs: nodejs#46674 PR-URL: nodejs#47791 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Add a "table" parameter to getCoverageReport. Keep the tap coverage output intact. Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot. Group uncovered lines as ranges. Add yellow color for coverage between 50 and 90. Refs: nodejs#46674 PR-URL: nodejs#47791 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Add a "table" parameter to getCoverageReport. Keep the tap coverage output intact. Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot. Group uncovered lines as ranges. Add yellow color for coverage between 50 and 90. Refs: #46674 PR-URL: #47791 Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Add a "table" parameter to getCoverageReport.
Keep the tap coverage output intact.
Change the output by adding padding and truncating the tables' cells. Add separation lines for table head/body/foot.
Group uncovered lines as ranges.
Add yellow color for coverage between 50 and 90.
Refs: #46674