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.

Not working with JEST

See original GitHub issue

I am using JEST for testing and I am generating the coverage report in cobertura format, and this error shows up when the workflow is run.

Coverage File: /github/workspace/coverage/cobertura-coverage.xml
Parsing Error: No package data found - /github/workspace/coverage/cobertura-coverage.xml

yml workflow file:

name: Node tests (with coverage)
on:
  push:
    branches:
      - '*'
      - '!master'
      - '!SS-test'
      - '!SS-UAT-test'
      - '!PS-prod'
  pull_request:
    branches:
      - 'master'
jobs:
  unit_tests:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      
      - name: Setup node
        uses: actions/setup-node@v1
        with:
          node-version: 14

      - name: Install npm packages
        run: npm ci
      
      - name: Test 
        run: npm run test:coverage

      - name:
        uses: actions/upload-artifact@v3
        with:
          name: my-artifact
          path: "coverage/" # or path/to/artifact

      - name: Code Coverage Report
        uses: irongut/CodeCoverageSummary@v1.3.0
        with:
          filename: "/coverage/cobertura-coverage.xml"
          badge: true
          fail_below_min: true
          format: markdown
          hide_branch_rate: false
          hide_complexity: true
          indicators: true
          output: both
          thresholds: '60 80'

could someone please help me figure out whats going wrong

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ScottGuymercommented, Mar 17, 2023

Is there a solution for this for when you have a project that actually doesn’t have any tests yet? @irongut

We’re using this in a NX monorepo, so all apps/packages doesn’t have tests yet.

Coverage File: /github/workspace/coverage/apps/blockchain-api/cobertura-coverage.xml
Parsing Error: No package data found - /github/workspace/coverage/apps/blockchain-api/cobertura-coverage.xml
Coverage File: /github/workspace/coverage/apps/web-app/cobertura-coverage.xml
Coverage File: /github/workspace/coverage/apps/notifications-api/cobertura-coverage.xml
Coverage File: /github/workspace/coverage/apps/platform-api/cobertura-coverage.xml

I ran into this myself.

If you remove the test command from the package.json in the package with no tests then lerna/nx will not run the command in that package… And so you get no coverage files for that package.

Not ashamed to say, it took me far too long to think of this “workaround”

1reaction
karthik2265commented, Sep 15, 2022

Hey @BeyondEvil , I realized this after a bit of research, If you are using JEST, we can set coverage threshold and we don’t need a github action.

take a look at this: https://jestjs.io/docs/configuration#coveragethreshold-object

Thank You

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
javascript - Jest command not recognized
2) Install locally · If any of the above don't work, try reinstalling jest . · If it still doesn't work, try removing...
Read more >
Troubleshooting · Jest
Try running Jest with --no-watchman or set the watchman configuration option to false . Also see watchman troubleshooting. Tests are Extremely Slow on...
Read more >
[Bug]: jest.mock not working with ESM support activated ...
This pattern worked with CJS, because babel-jest transformer is moving jest.mock calls at the top of the file (above any require statement).
Read more >
How to fix Jest and Mock Service Worker integration errors
This time it is complaining that in jest.setup.js file above I used import . The fix for this was quite easy, I rename...
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