Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating report failed with TypeError: Cannot convert undefined or null to object #388

Open
QuentinLemCode opened this issue Jul 26, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@QuentinLemCode
Copy link

QuentinLemCode commented Jul 26, 2023

Describe a bug

Hello,
The action fail on main branches while it works on PR.
See the screenshot below and the report.json gist link

Expected behavior

The report is generated and a comment is added to the PR

Details

  • Action version: latest
  • OS, where your action is running (windows, linux): linux
  • action.yml file
  unit-tests:
    name: Unit Tests
    runs-on: ubuntu-latest
    timeout-minutes: 10
    env:
      NODE_ENV: test
    steps:
      - uses: actions/checkout@v3
      - uses: ./.github/actions/setup-node
      - name: Run Tests
        run: npm run test:ci
      - name: Save coverage report
        uses: actions/upload-artifact@v3
        with:
          name: coverage-report
          path: coverage
          retention-days: 1
      - name: Publish Coverage
        uses: artiomtr/jest-coverage-report-action@f1a1382101d9b92b38e3df05c9ed89a834af97c8
        with:
          coverage-file: ./coverage/report.json
          github-token: ${{ secrets.GITHUB_TOKEN }}
          threshold: 90
          annotations: coverage
          skip-step: all
  • Screenshots

image
image
https://gist.github.com/QuentinLemCode/3600641d8b3db7c6c5753c1896ce9224

Additional context

@QuentinLemCode QuentinLemCode added the bug Something isn't working label Jul 26, 2023
@ArtiomTr
Copy link
Owner

Hello @QuentinLemCode 👋,

Looks like the coverage file coverage/report.json has an invalid format. Please make sure you're generating a coverage file with the necessary flags: https://github.com/ArtiomTr/jest-coverage-report-action#customizing-test-script

@QuentinLemCode
Copy link
Author

QuentinLemCode commented Jul 26, 2023

@ArtiomTr Thanks for reply
I don't see what's wrong with my report.json file.
Also the jest command line is the same than in other branches, but it fail only on main.
Can you take a look at the gist?

@ArtiomTr
Copy link
Owner

Try to specify:

        with:
          coverage-file: ./coverage/report.json
          base-coverage-file: ./coverage/report.json # this line added
          github-token: ${{ secrets.GITHUB_TOKEN }}
          threshold: 90
          annotations: coverage
          skip-step: all

This will skip coverage comparison. This is not ideal, but at least your CI will work for now. I need more time to dig deeper into this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants