-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
TypeError: Cannot convert undefined or null to object #343
Comments
I also noticed that I am using a resolver for jest which is needed because I am using typescript. Could this be the reason? I tried commenting it out and running locally the tests all passed but I am not comfortable disabling this. Also, I noticed the generated report is pretty much the same as the other one. I also did a push with this change just to check if the result is different but it still failed. Here are the logs:
|
Hello @dagadbm 👋, Looks like an error is being thrown on this here:
That's a function that is counting how many total statements/functions are in your coverage map. So, in order to clearly understand where is an issue, I need to see full coverage maps. To do this, add logging into your action.yaml file: name: Frontend build and test CI
on:
pull_request:
branches: [ "master", "dev" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 12
uses: actions/setup-node@v3
with:
node-version: '12'
cache: 'npm'
- run: npm ci
- run: npm run graphql:generate
- run: npm run lint
- run: npm run build:old-node-version --if-present
# run tests and collect coverage reports to send to jest-coverage-report-action
- run: npm test -- --ci --coverage --json --testLocationInResults --outputFile=client-coverage-report.json
- run: cat client-coverage-report.json # <------------- add this line to log coverage map
- uses: ArtiomTr/jest-coverage-report-action@v2
id: coverage
with:
output: report-markdown
coverage-file: client-coverage-report.json
base-coverage-file: client-coverage-report.json
- uses: marocchino/sticky-pull-request-comment@v2
with:
message: ${{ steps.coverage.outputs.report }} Then run the action one more time and send me a JSON, that is being logged. |
the file is so huge (25MB) I had to send it as a zip. i even tried to use pastebin but couldnt 😅 |
let me know when I can delete it from the issue. |
Well, that's a really interesting case - some files have non-standard coverage maps. For instance, file By default, report object looks like: {
coverageMap: {
['/filename']: {
statementMap: { /* information about statements */ }
}
}
} However, yours looks like: {
coverageMap: {
['/filename']: {
+ data: {
statementMap: { /* information about statements */ }
+ }
}
}
} So, the action tries to read non-existing property and fails. Fortunately, that will be an easy fix 😄 |
@dagadbm, the fix is now available under |
Thank you!!!!!!!!!!! Omg!!
…On Sat, Feb 4, 2023, 09:52 Artiom Tretjakovas ***@***.***> wrote:
@dagadbm <https://github.com/dagadbm>, the fix is now available under
v2.1.3 (v2) tag
—
Reply to this email directly, view it on GitHub
<#343 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD7WGR2HLSKU5C5F7BFZPN3WVYREZANCNFSM6AAAAAAUQDSH2I>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I'll test this out when I can and let you know but hopefully it should be
good.
Btw have you considered yourself implement the sticky message? Instead of
people having to rely on yet another third party git action?
…On Sat, Feb 4, 2023, 10:41 David Maia ***@***.***> wrote:
Thank you!!!!!!!!!!! Omg!!
On Sat, Feb 4, 2023, 09:52 Artiom Tretjakovas ***@***.***>
wrote:
> @dagadbm <https://github.com/dagadbm>, the fix is now available under
> v2.1.3 (v2) tag
>
> —
> Reply to this email directly, view it on GitHub
> <#343 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AD7WGR2HLSKU5C5F7BFZPN3WVYREZANCNFSM6AAAAAAUQDSH2I>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
|
Yeah, sticky comments are implemented in this action, actually, that's the default behaviour: jest-coverage-report-action/action.yml Lines 50 to 53 in 8baf903
I changed the default example because I was thinking that would fix an issue with permissions on public repos (#313). However, that not worked 😞 So I decided to leave the example as is and change it when this issue will be fixed. If you don't want to use third-party action for comments, you can change your workflow file to use built-in functionality: name: Frontend build and test CI
on:
pull_request:
branches: [ "master", "dev" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 12
uses: actions/setup-node@v3
with:
node-version: '12'
cache: 'npm'
- run: npm ci
- run: npm run graphql:generate
- run: npm run lint
- run: npm run build:old-node-version --if-present
# run tests and collect coverage reports to send to jest-coverage-report-action
- run: npm test -- --ci --coverage --json --testLocationInResults --outputFile=client-coverage-report.json
- uses: ArtiomTr/jest-coverage-report-action@v2
- id: coverage
with:
- output: report-markdown
coverage-file: client-coverage-report.json
base-coverage-file: client-coverage-report.json
- - uses: marocchino/sticky-pull-request-comment@v2
- with:
- message: ${{ steps.coverage.outputs.report }} |
Unfortunately even though now it works nothing is shown in the coverage
part because the side exceeds the limit.
How do you handle big code bases in this case?
-
|
Yeah, details are omitted if the report size exceeds the limits (Github limits comment size to 65535 symbols). However, I think we could improve the algorithm and show as many details as possible. I will create a separate issue for this. |
I have already looked through the two other issues regarding this problem but I honestly am at a loss on how to fix this.
Here is the log:
This is the config:
I also ran the npm test command locally on my machine that is using node 12 and I got the expected result:
and here is my jest.config.js
The text was updated successfully, but these errors were encountered: