Skip to content

[Bug]: v8 coverage lowers when more tests are executed #14766

Open
@TWiStErRob

Description

@TWiStErRob

Version

29.7.0

Steps to reproduce

  1. Clone https://github.com/TWiStErRob/repros/tree/main/jest/v8-flaky-coverage
  2. npm install
  3. npm test -- --runInBand wrapped.test.js -> tests pass, coverage 100%
  4. npm test -- --runInBand -> tests pass, coverage missing lines

Expected behavior

Everything passes and coverage is better or equivalent to when only a single test is executed.

image

Actual behavior

File that is covered by a single test file to 100% loses coverage when an additional test is executed. The additional test calls the original function.

image

Additional context

Anything relevant changed in the repro will make it work correctly. So:

  • v8 -> babel
  • changing the order of execution of tests (sorted.js < -> >) ✅
    We used a testSequencer to consistently reproduce the issue, otherwise it was flaky!
  • changing the order via removing --runInBand
    We also used this to consistently reproduce the issue, otherwise it was flaky!

Environment

System:
    OS: macOS 14.1.2
    CPU: (12) arm64 Apple M2 Pro or (10) arm64 Apple M1 Pro
  Binaries:
    Node: 20.10.0 - /opt/homebrew/opt/node@20/bin/node
    npm: 10.2.3 - /opt/homebrew/opt/node@20/bin/npm
  npmPackages:
    jest: ^29.7.0 => 29.7.0 

Also on github actions ubuntu-latest (so Ubuntu 22.04 and x64).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions