jest-coverage-report-action icon indicating copy to clipboard operation
jest-coverage-report-action copied to clipboard

Show # of Covered Lines Diff in Summary

Open grant opened this issue 2 years ago • 5 comments

Idea

Our codebase always shows coverage diff results that aren't significant. Examples:

  • -0%
  • 7162/33582 statements covered

I'd like to report the exact number of statements/branches/functions/lines covered and added/removed. For small PRs it will show something like 0 of 4 statements added have coverage.

Description

Here's a proposal.

Actual

St.:grey_question:
Category Percentage Covered / Total
🔴 Statements
21.33% (-0% 🔻)
7162/33582
🔴 Branches
12.93% (-0% 🔻)
2412/18660
🔴 Functions 18.52% 1764/9524
🔴 Lines
21.32% (-0% 🔻)
6525/30599

Desired

St.:grey_question:
Category Percentage Covered / Total
🔴 Statements
21.33% (-0% 🔻)
7162/33582 (0/4)
🔴 Branches
12.93% (-0% 🔻)
2412/18660 (0/1)
🔴 Functions 18.52% 1764/9524 (0/1)
🔴 Lines
21.32% (-0% 🔻)
6525/30599 (0/4)

Alternatives

Not show the diff number, only show the diff percent.

Additional context

Happy to create a PR, or just start a discussion.

https://github.com/ArtiomTr/jest-coverage-report-action/blob/952a05968ad9e0b4ab2ab221a8d7d72e621aec51/src/format/summary/formatCoverageSummary.ts#L29

grant avatar Apr 12 '23 18:04 grant

Hey @grant :wave:,

Great idea! I think that report could just contain statement/branch/etc. delta, if percent change is insignificant. For instance, in your case, this could look like:

St.:grey_question:
Category Percentage Covered Total
🔴 Statements 21.33% 7162
33582 (+4 🔺)
🔴 Branches 12.93% 2412
18660 (+1 🔺)
🔴 Functions 18.52% 1764 9524
🔴 Lines 21.32% 6525
30599 (+4 🔺)

So if percent delta is below some threshold (for instance 0.1 percent), then action should generate information about exact category changes, not percents.

I think, with this format, the report will contain more useful information in large codebases, while being simple in smaller repositories. Let me know what you think about this solution!

ArtiomTr avatar Apr 12 '23 20:04 ArtiomTr

Yeah that resulting UI would be perfect @ArtiomTr!

I think the 0.1 threshold sounds reasonable, users don't get much info from that percentage change, but may get some useful info from the line change at that level.

Not sure how hard it is to change that; happy to test it.

grant avatar Apr 12 '23 20:04 grant

@grant PRs are welcome, if you have any questions regarding the code - feel free to ping me 🙌

ArtiomTr avatar Apr 12 '23 20:04 ArtiomTr

I'll try to get to a PR for this, thanks!

grant avatar Apr 13 '23 02:04 grant

Note: I'm not able to get to a PR for this, tried but it was a little complicated setting things up. We're using a different reporting method, but could use this action in the future.

grant avatar Apr 24 '23 16:04 grant