Skip to content

Report test coverage of statements and branches #7100

@jakeboone02

Description

@jakeboone02

What is the problem this feature would solve?

bun test --coverage reports coverage percentages for functions and lines like Jest/Vitest/etc, but those also report coverage for statements and branches.

More granular reporting like this is especially helpful to ensure full coverage on terse code like chained ternaries, for example.

const chainedTernary =
  condition === 1
    ? result1
    : condition === 2
      ? result2
      : result3;

I realize this type of code isn't everyone's cup of tea, but it would be really nice to get the statement and branch coverage numbers from Bun.

What is the feature you are proposing to solve the problem?

Include statement and branch coverage percentages in bun test --coverage reports. Something like this in the CLI:

---------------|---------|---------|---------|---------|-------------------
File           | % Funcs | % Lines | % Stmts | % Brnch | Uncovered Line #s
---------------|---------|---------|---------|---------|-------------------
All files      |  100.00 |  100.00 |   90.00 |   80.00 |
 src/index.ts  |  100.00 |  100.00 |   90.00 |   80.00 | 25,50
---------------|---------|---------|---------|---------|-------------------

                                   ^^^^^^^^^^^^^^^^^^^^

I assume this would affect the lcov output as well (see #4015).

What alternatives have you considered?

Sticking with Jest for now.

Metadata

Metadata

Assignees

Labels

bun:testSomething related to the `bun test` runnerenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions