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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong branch coverage percentage #7532

Closed
andreamatt opened this issue Dec 18, 2018 · 2 comments
Closed

Wrong branch coverage percentage #7532

andreamatt opened this issue Dec 18, 2018 · 2 comments

Comments

@andreamatt
Copy link

andreamatt commented Dec 18, 2018

馃悰 Bug Report

Jest reports wrong branch coverage percentage. Uncovered lines are correct.

To Reproduce

EDIT

  • added console.log(1/2) so that branches are not empty. Still wrong/unexpected results
function foo(a, b) {
    if (a && b) {
        console.log('1');
    } else {
        console.log('2');
    }
    return 0;
}

tests with only 1 function call
foo(0,0) gives 50%
foo(0,1) gives 50%
foo(1,0) gives 75%
foo(1,1) gives 75%

Uncovered lines are always correct and if both branches are covered it gives 100%.

Expected behavior

There is only 1 'if-else', so branch coverage should always be a multiple of 0.5.

Run npx envinfo --preset jest

System:
    OS: Windows 10
    CPU: (4) x64 Intel(R) Core(TM) i3-7100U CPU @ 2.40GHz
Binaries:
    Node: 10.10.0 - D:\Software\nodejs\node.EXE
    npm: 6.4.1 - D:\Software\nodejs\npm.CMD
@rickhanlonii
Copy link
Member

Hey @andreamatt, we use istanbuljs for coverage reporting, they may be able to explain better

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
@SimenB SimenB removed the Question label Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants