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

[Bug]: Divergent branch coverage in JS and TS reports #4208

Closed
bertschneider opened this issue Sep 25, 2023 · 1 comment
Closed

[Bug]: Divergent branch coverage in JS and TS reports #4208

bertschneider opened this issue Sep 25, 2023 · 1 comment

Comments

@bertschneider
Copy link

bertschneider commented Sep 25, 2023

Version

29.1.1

Steps to reproduce

  1. Clone git@github.com:bertschneider/ts-jest-branch-coverage-reproducer.git
  2. Read readme.md for detailed description of the issue
  3. Generate JS coverage report via npm run test:js
    • Notice that report coverage/coverage-final.json contains the key b with the value {"0":[2,1],"1":[1,1]}, so the invocations of the contained if and else branches were tracked correctly
  4. Generate TS coverage report via npm run test:ts
    • Notice that report coverage/coverage-final.json contains the key b with the value {"0":[2],"1":[1]}, so the invocations of the contained else branches were not tracked
    • Also notice that the report contains branchMap entries with missing locations for the else branches

Expected behavior

Both, the JS and TS, coverage reports should result in the same number of discovered branches and the same number of invocations of the else branches.

Actual behavior

The TS coverage report has a lower number of discovered branches, it seems that the else branches are missing.

Debug log

ts-jest.log

Additional context

It seems that the coverage instrumentation is correct but somewhere along the way invocations of the else branches in imported TS files are lost.

Environment

System:
    OS: Linux 6.4 Fedora Linux 38 (Workstation Edition)
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
  Binaries:
    Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
  npmPackages:
    jest: 29.7.0 => 29.7.0
@bertschneider bertschneider changed the title [Bug]: [Bug]: Divergent branch coverage in JS and TS reports Sep 25, 2023
@bertschneider
Copy link
Author

Further investigation brought me to an istanbul issue: istanbuljs/istanbuljs#706.
This issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant