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

Error on a threshold failure

Open gromanas opened this issue 3 years ago • 4 comments

Describe a bug

Hello! Thank you very much for your actions. Looks great! I am using a specific threshold on jest.config.js and I have seen that in case of a failure (not catching this threshold), an error occured.

Jest: "global" coverage threshold for statements (85%) not met: 75.08%
Jest: "global" coverage threshold for branches (85%) not met: 82.66%
Jest: "global" coverage threshold for lines (85%) not met: 75.08%
Jest: "global" coverage threshold for functions (85%) not met: 25.71%

Test Suites: 12 skipped, 9 passed, 9 of 21 total
Tests:       55 skipped, 32 passed, 87 total
Snapshots:   0 total
Time:        13.035 s
Ran all test suites.
Test results written to: report.json
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:unit: `npm run clean:coverage && jest -c jest.config.js "--ci" "--json" "--coverage" "--testLocationInResults" "--outputFile=report.json"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test:unit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-02-17T14_03_29_662Z-debug.log
Running tests failed
Error: Error: The process '/opt/hostedtoolcache/node/14.19.0/x64/bin/npm' failed with exit code 1
Error: The process '/opt/hostedtoolcache/node/14.19.0/x64/bin/npm' failed with exit code 1
    at jp._setResult (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.3/dist/index.js:10:17263)
    at jp.CheckComplete (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.3/dist/index.js:10:[168](https://github.com/camelotls/ctp-iwg-framework/runs/5233154302?check_suite_focus=true#step:5:168)53)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.3/dist/index.js:10:15846)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
Running tests ended

Expected behavior

Maybe a more proper error handling.

Details

  • Action version: v2.0.3
  • OS, where your action is running (windows, linux): ubuntu-latest
  • action.yml file
      name: Unit Tests
      on: push
      jobs:
         unit:
           runs-on: ubuntu-latest
           steps:
               - name: Checkout
                 uses: actions/checkout@v2
    
              - name: NodeJS setup
                 uses: actions/[email protected]
                 with:
                    node-version: "14.x"
    
              - name: Install npm packages
                run: npm install
    
              - name: Coverage
                uses: ArtiomTr/[email protected]
                with:
                test-script: npm run test:unit
    
    

gromanas avatar Feb 18 '22 10:02 gromanas

Hey, I'm also receiving an error on line coverage threshold failure, although my error looks exactly like the one here:

https://github.com/ArtiomTr/jest-coverage-report-action/issues/198#issuecomment-1011542129

When the threshold is met the report generates quite nicely. I'm using [email protected]

Error: TypeError: Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object
    at Function.values (<anonymous>)
    at P1 (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:28:4923)
    at Qn (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:28:5065)
    at Gm (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:37:33)
    at Xm (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:49:261)
    at /home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:52:1555
    at je (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:51:162)
    at xw (/home/runner/work/_actions/ArtiomTr/jest-coverage-report-action/v2.0.5/dist/index.js:52:1517)
Generating report ended
Begin report publish...
Report publish skipped
Report publish ended
Begin failed tests' annotations publication...
Failed tests' annotations publication skipped
Failed tests' annotations publication ended
Begin coverage annotations publication...
Coverage annotations publication ended
Error: Jest coverage report action failed
Error: Process completed with exit code 1.

Thanks for the project and for looking into this.

lucasgray-alloy avatar Mar 22 '22 02:03 lucasgray-alloy

This seems like a critical feature. Error happens to me even if my global coverage threshold is set to 0. Is there any workaround for this?

hsalinasbairesdev avatar Jun 03 '22 14:06 hsalinasbairesdev

Hello @lucasgray-alloy and @hsalinasbairesdev :wave:,

Sorry for late response. I think the issues you're facing are not related to original one - the problem begins in the generating report stage, so the threshold value should not affect it. Your issues look similar to #268, where the problem was with an invalid report structure. I've described possible solutions in this comment.

ArtiomTr avatar Jun 07 '22 10:06 ArtiomTr

I have the same issue as above with version 2.2.1, when threshold is not met action is failing: Screenshot 2023-03-06 at 16 14 52

action setup (base code coverage is downloaded correctly and if I remove that part I got the same issue): Screenshot 2023-03-06 at 16 36 33 Screenshot 2023-03-06 at 16 41 20

Report file is generated correctly though: report.json.zip

OlgaBielkina avatar Mar 06 '23 15:03 OlgaBielkina

Issue was addressed in v2.3.0 release. If still experiencing it - feel free to reopen it.

ArtiomTr avatar Mar 03 '24 16:03 ArtiomTr