-
Notifications
You must be signed in to change notification settings - Fork 82
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
npm run test:unit:coverage skips tests that run individually #242
Comments
Could you share a sample repository showcasing this bug? |
Thanks for trying to help. It is happening with one of our managed packages so unfortunately it is not possible to share the repo. Can you at least point me in the right direction? Under what circumstances are tests skipped in the coverage table (if any)? I am happy to share any config files, log files, or JEST-related files if that would help. Just let me know. |
This package is a simple wrapper around jest (code).
No need to share your entire managed package code. Something that would be really helpful, would be to share a brand new SFDX project with a minimal setup showcasing your coverage issue. I am interested in how the project is set up: which version of the different packages you are running (including the versions frozen lockfile), how is the repository structure, the jest configuration, and the test code itself. |
Since this issue is still open, our team encountered the same behavior and found clearing the Jest cache was our easiest workaround to solve it. So something like:
would cause coverage of all files to be correctly reported, whereas running an individual component's test, then running without clearing the cache, would often cause the individually-run component to not show up in the report. For your scripts file, you can simplify it to something like:
which is what we've had for some time. |
I have tests that run individually but they are not shown in the coverage summary table when I run npm run test:unit:coverage.
Typically I am working on a test and it initially appears in the coverage summary table. Then it simply disappears from the coverage summary after subsequent runs.
The only way I have been able to get the test to reappear in the coverage summary is if I blow away my VSCode project/folder and recreate it from scratch. Even this does not work for all the missing tests all the time. Very strange.
I am using a vanilla installation of all the SFDX tools. I have changed nothing in the JEST config files other than adding:
"test:unit:coverage": "sfdx-lwc-jest --coverage"
to my package.json.
For example, here is a test that runs fine individually:
`npm run test:unit dispatchConsoleCalendarCell.test.js
PASS force-app/main/default/lwc/dispatchConsoleCalendarCell/tests/dispatchConsoleCalendarCell.test.js
c-dispatch-console-calendar-cell
√ pto calendar cell (59 ms)
√ preferred location calendar cell (28 ms)
√ unassigned load calendar cell (30 ms)
√ dispatched relay load calendar cell - on schedule (42 ms)
√ dispatched relay load calendar cell - behind schedule (31 ms)
√ dispatched relay load calendar cell - schedule status unknown (27 ms)
√ delivered relay load calendar cell (29 ms)
√ undefined cell (14 ms)
Test Suites: 1 passed, 1 total
Tests: 8 passed, 8 total
Snapshots: 0 total
Time: 2.804 s
Ran all test suites matching /dispatchConsoleCalendarCell.test.js/i.`
But if I run the npm run test:unit:coverage command it is skipped in the coverage list:
...
customerQuoteBuilder | 30.62 | 20.39 | 43.97 | 30.68 | customerQuoteBuilder.js | 30.62 | 20.39 | 43.97 | 30.68 | 265,333-337,367,389,427-464,480,491,502,513,537-543,567-569,577-596,626-1072,1130-1220,1233,1241-1283 customerShipmentTracking | 0 | 0 | 0 | 0 | customerShipmentTracking.js | 0 | 0 | 0 | 0 | 4-330 customerShipmentTrackingProgressIndicator | 0 | 100 | 0 | 0 | customerShipmentTrackingProgressIndicator.js | 0 | 100 | 0 | 0 | 4-24 dispatchConsoleAssignments | 94.44 | 80.77 | 100 | 94.38 | dispatchConsoleAssignments.js | 94.44 | 80.77 | 100 | 94.38 | 333-340 dispatchConsoleDataTable | 100 | 100 | 100 | 100 | dispatchConsoleDataTable.js | 100 | 100 | 100 | 100 | dispatchConsoleDriverFilter | 92.4 | 69.23 | 82.93 | 92.35 | dispatchConsoleDriverFilter.js | 92.4 | 69.23 | 82.93 | 92.35 | 208,218,242,267,286,307-312,347-352,417-418 dispatchConsoleFleetAssignment | 35.66 | 32.73 | 28.07 | 35.42 | dispatchConsoleFleetAssignment.js | 35.66 | 32.73 | 28.07 | 35.42 | 210,229,240,251,265,283-301,321-322,332,368,377-397,409-446,458,471-741,752,755,766-770 dispatchConsoleLoadFilter | 85.51 | 71.21 | 76.47 | 85.45 | dispatchConsoleLoadFilter.js | 85.51 | 71.21 | 76.47 | 85.45 | 233,258-272,282,306,331-350,371-376,413-417,509-510,570 driverLocation | 100 | 66.67 | 100 | 100 |
....
Thanks in advance for your help.
The text was updated successfully, but these errors were encountered: