Skip to content

bun test --coverage marks first import line uncovered for class extending factory-call result #29691

Closed

Description

@tatemz

What version of Bun is running?

1.3.13+bf2e2cecf

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

Create these files:

bunfig.toml

[test]
coverage = true
coverageReporter = [\"text\", \"lcov\"]

dep.ts

export const Base = () => class {};

subject.ts

import { Base } from \"./dep\";
export class Derived extends Base() {}

subject.test.ts

import { describe, expect, it } from \"bun:test\";
import { Derived } from \"./subject\";

describe(\"factory-extends\", () => {
  it(\"loads the class\", () => {
    expect(Derived.name).toBe(\"Derived\");
  });
});

Then run:

bun test --coverage

On my machine this prints:

bun test v1.3.13 (bf2e2cec)

subject.test.ts:
(pass) factory-extends > loads the class
------------|---------|---------|-------------------
File        | % Funcs | % Lines | Uncovered Line #s
------------|---------|---------|-------------------
All files   |   25.00 |   75.00 |
 dep.ts     |   50.00 |  100.00 |
 subject.ts |    0.00 |   50.00 |
------------|---------|---------|-------------------

 1 pass
 0 fail
 1 expect() calls
Ran 1 test across 1 file. [11.00ms]

The generated coverage/lcov.info contains:

TN:
SF:subject.ts
FNF:1
FNH:0
DA:1,0
DA:2,30
LF:2
LH:1
end_of_record

DA:1,0 is the bad line-level accounting here: line 1 is just the import, but the module is imported and line 2 is evaluated.

What is the expected behavior?

subject.ts should report 100% line coverage for this repro. The first import line should not be marked uncovered when the module is loaded.

If Bun counts a synthetic constructor/function for class Derived extends Base() {}, I would still expect that synthetic function not to penalize source coverage, since there is no user-authored constructor body to exercise.

What do you see instead?

Bun reports subject.ts at 50.00 line coverage and records the first import line as uncovered in lcov (DA:1,0). It also reports 0.00 function coverage for subject.ts.

Additional information

This looks related to coverage bugs like #7025, but I think this repro is narrower and shows an additional line-coverage problem: the import line itself is recorded as uncovered when the file contains an empty class body extending a factory-call result.

Activity

  1. robobun commented on Apr 24, 2026

    @robobun
    Collaborator

    ✅ Reproduced — DA:1,0 for the import line comes from JSC filing a synthetic default class constructor range against the user sourceID with offsets that live in a different (synthetic) source. Fix in progress → #29693

  2. added a commit that references this issue on May 4, 2026
    8dcc82e
  3. added a commit that references this issue on Oct 20, 2026
    6f58f6b
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions