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

stages.checkThreshold failed

Open hsnice16 opened this issue 1 year ago • 8 comments

Describe a bug

I have added a coverageThreshold value to 0, but still stages.checkThreshold is failing

// package.json
{
   ...
     "jest": {
     ...
    "coverageThreshold": {
      "global": {
        "lines": 0
      }
    }
  }
}
// workflow
- name: 📝 Coverage Report
        uses: ArtiomTr/jest-coverage-report-action@v2
        with:
          coverage-file: ./apps/extension/coverage/coverage-final.json
          base-coverage-file: ./apps/extension/coverage/coverage-final.json
Screenshot 2023-06-11 at 1 56 49 PM

hsnice16 avatar Jun 11 '23 08:06 hsnice16

Hi, same problem too! image

      - name: Publish coverage report
        uses: ArtiomTr/jest-coverage-report-action@v2
        with:
          skip-step: all
          coverage-file: ./coverage/coverage-final.json
          base-coverage-file: ./coverage/coverage-final.json

osnoser1 avatar Jun 15 '23 04:06 osnoser1

Hi, same problem too!

thierryVerrier avatar Jun 16 '23 10:06 thierryVerrier

Same problem here.

AjaSharma93 avatar Jun 20 '23 17:06 AjaSharma93

I also experiencing this, any update about this? @ArtiomTr

I even provide low threshold in the workflow file

with:
  threshold: 10

but seems no effect at all

devinekadeni avatar Aug 10 '23 07:08 devinekadeni

UPDATE: after debugging on the source code turns out the problem was the generated coverage file have no coverageMap property. This thread would explain everything https://github.com/ArtiomTr/jest-coverage-report-action/issues/244#issuecomment-1097360277. Now it works on my side

devinekadeni avatar Aug 10 '23 10:08 devinekadeni

UPDATE: after debugging on the source code turns out the problem was the generated coverage file have no coverageMap property. This thread would explain everything #244 (comment). Now it works on my side

Hi @devinekadeni! I'm facing the same issue here. can you specify how did you make it work on your side?

alisweatworks avatar Nov 28 '23 23:11 alisweatworks

UPDATE: after debugging on the source code turns out the problem was the generated coverage file have no coverageMap property. This thread would explain everything #244 (comment). Now it works on my side

Hi @devinekadeni! I'm facing the same issue here. can you specify how did you make it work on your side?

@alisweatworks this is what I did on my workflow file

- name: Run test with coverage
   run: npm run test:coverage -- --json --outputFile="coverage/coverage-report.json"

- uses: ArtiomTr/jest-coverage-report-action@v2
   with:
     skip-step: all
     annotations: none 
     coverage-file: coverage/coverage-report.json
     base-coverage-file: coverage/coverage-report.json
// package.json
...
"scripts": {
    "test:coverage": "jest --coverage",
}
...

devinekadeni avatar Nov 29 '23 00:11 devinekadeni

@devinekadeni Thanks! I have the same thing only with yarn. My issue is that if I include a threshold in jest.config.ts, e.g.

  coverageThreshold : {
    global :{
      branches: 90,
      lines: 90,
      functions: 90,
      statements: 90
    }
  }

If my tests pass but don't meet the threshold, the job will fail with exit code 1 but the coverage report won't be generated (like shown here). I wonder what I'm doing wrong.

I see this in github logs:

...
...
Jest: "global" coverage threshold for statements (90%) not met: 86.22%
Jest: "global" coverage threshold for branches (90%) not met: 86.84%
Jest: "global" coverage threshold for lines (90%) not met: 85.39%
Jest: "global" coverage threshold for functions (90%) not met: 87.34%

Test Suites: 26 passed, 26 total
Tests:       182 passed, 182 total
Snapshots:   0 total
Time:        [39](https://github.com/SweatWorks/revenue-cycle-api/actions/runs/7033893498/job/19140703600#step:9:40).987 s
Test results written to: coverage/report.json
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

hence the next step which is coverage report wouldn't be triggered

alisweatworks avatar Nov 29 '23 14:11 alisweatworks