1

I have a github action to test the code coverage of unit tests written in JEST, and using Code Coverage Summary action to check the lines coverage to be between 60-80.

I get the following error when the job is run

Parsing Error: No package data found 

tests.yml 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/[email protected]
        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'

cobertura-coverage.xml file:

<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage lines-valid="0" lines-covered="0" line-rate="NaN" branches-valid="0" branches-covered="0" branch-rate="NaN" timestamp="1661235506222" complexity="0" version="0.1">
  <sources>
    <source>C:\guardian group\c360-account-services</source>
  </sources>
  <packages>
  </packages>
</coverage>

code coverage summary github action: https://github.com/marketplace/actions/code-coverage-summary

1 Answer 1

1

I figured out the issue after a few trail and error, the issue is that I only had dummy test cases and do not have any real test cases for any of the functions in the project and this causes the parse error i.e package data not found which means no coverage is found at all because there are no real test cases.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.