[Bug]: Running coverage on untested files UnhandledPromiseRejectionWarning
See original GitHub issueVersion
28.0.X
Steps to reproduce
- Clone my repo:
https://gitlab.com/SalahAdDin/challenge-legamart
- Install everything:
yarn
. - Run the tests with coverage:
yarn test:ci
. - Run the tests watching them:
yarn test --watch
. - Check the console.
Expected behavior
It should not give any error, show the coverage table and create the coverage folder with all gathered data.
Actual behavior
At running all the tests we have:
st:ci
yarn run v1.22.19
$ yarn test --coverage
$ jest --passWithNoTests --no-cache --runInBand --coverage
PASS src/application/context.test.tsx
PASS src/application/provider.test.tsx
Running coverage on untested files...(node:34366) UnhandledPromiseRejectionWarning
(Use `node --trace-warnings ...` to show where the warning was created)
(node:34366) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:34366) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
✨ Done in 9.23s.
And we have no any coverage report, while with watch we have:
PASS src/application/context.test.tsx
PASS src/application/provider.test.tsx
Running coverage on untested files...(node:34578) UnhandledPromiseRejectionWarning
(Use `node --trace-warnings ...` to show where the warning was created)
(node:34578) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:34578) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Debug log
Additional context
We are trying to make it work together with Jest 28
and Testing Library.
We tested it with all versions of 28.0.X
and It didn’t work.
You can check we are not testing anything asyncronical, so, we can’t understand what’s the problem.
Environment
npx: installed 1 in 1.499s
System:
OS: macOS 12.4
CPU: (10) x64 Apple M1 Pro
Binaries:
Node: 14.19.3 - ~/.nvm/versions/node/v14.19.3/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 6.14.17 - ~/.nvm/versions/node/v14.19.3/bin/npm
npmPackages:
jest: 28.1.1 => 28.1.1
Issue Analytics
- State:
- Created a year ago
- Comments:7
Top Results From Across the Web
Running coverage on untested files...Failed to collect ... - GitHub
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not...
Read more >Disable Coverage on Untested Files - Jest - Stack Overflow
I do not want to receive coverage reports on all of my untested files. When searching for an answer online, there are numerous...
Read more >Configuring code coverage in Jest, the right way
Code coverage makes possible to spot untested paths in our code. It is an important metric for determining the health of a project....
Read more >Configuring Code Coverage for TypeScript Files in Jest
That's because coverage takes several extra to process and I rarely need my code coverage run, so it just makes the testing feedback...
Read more >Jest code coverage report explained - Emma Goto
After you run the coverage command you'll get a summary report that looks ... How to track untested files with Jest's code coverage...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://jestjs.io/docs/configuration#coverageprovider-string
The bug looks valid to me. As a workaround, you can use
isolatedModules: true
see https://kulshekhar.github.io/ts-jest/docs/getting-started/options/isolatedModules