oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.29k stars 2.58k forks source link

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

Open LandonSchropp opened 5 months ago

LandonSchropp commented 5 months ago

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!

paperdave commented 5 months ago

my guess is likely an issue with sourcemap generation

LandonSchropp commented 3 months ago

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