Skip to content

bun test --coverage inaccurately reporting less than 100% coverage #9008

Open

Description

@LandonSchropp

What version of Bun is running?

1.0.28+705638470

What platform is your computer?

Darwin 23.2.0 x86_64 i386

What steps can reproduce the bug?

Apologies, but I couldn't find a more minimal reproduction of the issue outside of my current side project. However, it should be pretty fast to clone it and run the tests.

  1. git clone --depth 1 --branch bun-code-coverage-issue https://github.com/LandonSchropp/chess-fns
  2. cd chess-fns
  3. bun install
  4. bun test --coverage

What is the expected behavior?

The tests should pass with 100% code coverage.

What do you see instead?

The tests do not pass with 100% code coverage. Bun does not report any lines missed.

Screenshot 2024-02-19 at 8 11 24 PM

Through selectively commenting out code, I've narrowed down the issue to line 106 of parse-fen.ts. Commenting out this line and its surrounding if statement fixed the code coverage report, but makes a couple of my tests fail.

I can add a console.log statement before line 106 and see that it runs when running bun test --coverage.

Additional information

Have a nice day!

Activity

  1. small-angel commented on Feb 21, 2024

    @small-angel
    Contributor

    my guess is likely an issue with sourcemap generation

  2. LandonSchropp commented on Apr 7, 2024

    @LandonSchropp
    Author

    @Paperdave FYI, I tried this with Bun 1.1 and I'm still seeing this issue.

  3. Valle12 commented on Feb 18, 2025

    @Valle12

    @Jarred-Sumner Are there any news regarding this? I am in version 1.2.2 and bun still seems to "wrongly" report the coverage.

    Image

    To my knowledge I tested all methods and also every branch and bun reports no missing lines, but the function coverage is still underwhelming. Would be nice to have a correct coverage report to work with.

  4. dsogari commented on Mar 3, 2025

    @dsogari

    In my project, it reports uncovered lines for class getters/setters and properties with initializers.

  5. NullDev commented on May 24, 2025

    @NullDev

    +1 from me. It did initially report lines that weren't covered. So I fixed all of them.
    Now no lines are reported anymore, but I'm still not at 100%

    Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbun:testSomething related to the `bun test` runnersourcemaps

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions