question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: Running coverage on untested files UnhandledPromiseRejectionWarning

See original GitHub issue

Version

28.0.X

Steps to reproduce

  1. Clone my repo: https://gitlab.com/SalahAdDin/challenge-legamart
  2. Install everything: yarn.
  3. Run the tests with coverage: yarn test:ci.
  4. Run the tests watching them: yarn test --watch.
  5. 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

ts-jest.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:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
ahnpnlcommented, Jul 7, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found