question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Status of coverage icon indicators dont match thresholds set in jest.config.js

See original GitHub issue

Describe a bug

Firstly thanks for taking the time to create this GitHub action! It’s very nice and working pretty much exactly how we want it to.

We are however experiencing some confusion around the ‘Status of coverage’ traffic light icons in the first column of the report. As per below, both Branches and Functions are reporting that they are ‘Under the threshold’, however our jest.config.js has the thresholds set as per below so they should be ‘Slightly more then threshold’ image

  coverageThreshold: {
    global: {
      branches: 56,
      functions: 47,
      lines: 78,
      statements: 79,
    },
  }

Expected behavior

The ‘Status of coverage’ column icons should show the correct color based on what is set in the jest.config.js file.

Details

  • Action version: v2

  • OS, where your action is running (windows, linux): linux

  • action.yml file
      - uses: ArtiomTr/jest-coverage-report-action@v2
        with:
          test-script: yarn jest
          package-manager: yarn
          skip-step: install
          annotations: none
    
  • Screenshots

    image

Additional context

N/A

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:8
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
raspocommented, Oct 29, 2022

Thank you for the detailed response @ArtiomTr! I like the overall plan, the new status table makes a lot more sense, although the table would probably end up having a single row for most people. 🤷‍♂️

St. Threshold group Statements Branches Functions Lines
🟢 global 30% (10%) 70% 90% (40%) 50% (10%)

I think that as one of the first step I will have to add some tests for this part, because (as far as I can tell) the coverage is a bit lacking in this area 😅 Do you have any recommendations on how I should go about it? Like adding more tests to tests/run.test.ts or just refactor src/stages/checkThreshold.ts to make it more easily testable?!

0reactions
ArtiomTrcommented, Oct 26, 2022

Hello @raspo 👋,

Thank you for taking on this issue! I can’t remember, what was the reason for doing this. All this threshold-checking logic is implemented a bit incorrectly, so I’ve abandoned this logic in favour of the newly created package @covbot/jest-threshold. This package runs the same algorithm as jest does, but outputs much more useful output.

So, I wanted to rework the whole “status” logic a bit, to output more useful information in the report. Instead of showing generic statuses in the report, this algorithm could be performed:

  1. If retrieving coverage thresholds from jest configuration failed (the user doesn’t have them or just an unexpected error occurred), show the generic “statuses”, as it was before.
  2. If coverage thresholds were successfully extracted:
    1. Show the generic statuses, if only the “global” threshold is provided
    2. Otherwise, show the new “status” table.

The new status table could look like this:

St. Threshold group Statements Branches Functions Lines
🟢 global 30% (10%) 70% 90% (40%) 50% (10%)
🔴 packages/a 10% (77%) 50% 30% 20%
🟡 packages/b 50% 50% (27%) 70% 10% (32%)

Where the coverages are being shown per each threshold group, in the format “covered% (threshold%)”. I think this format would give the most correct presentation on how coverage changed in PR.

That’s a quite large task, so any help would be appreciated. For instance, you can begin by just replacing the old threshold-checking logic with a new one from the @covbot/jest-threshold package. Thank you in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
You can collect coverage from those files with setting forceCoverageMatch . JavaScript; TypeScript. /** @type {import('jest').Config} */
Read more >
Jest test coverage does not fail when threshold is not met
My understanding from the Jest documentation is that an error should be returned when coverage thresholds are not met. If thresholds aren't met ......
Read more >
vscode-jest - Visual Studio Marketplace
Build Status Coverage Status Visual Studio Marketplace ... The tests and status do not match or some tests showing question marks ...
Read more >
Frontend testing standards and style guidelines - GitLab Docs
The default timeout for Jest is set in /spec/frontend/test_setup.js . ... that the library knows what it's supposed to do and has test...
Read more >
VS Code tutorial - Wallaby.js
Regardless of your Files: Auto Save setting value in VS Code, Wallaby runs your tests as you type and you don't need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found