Skip to content

Test runner with isolation=none does not work with coverage #60023

@darrachequesne

Description

@darrachequesne

Version

v24.9.0

Platform

Linux home 5.15.0-153-generic #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

runner.js

import { run } from "node:test";
import { spec } from "node:test/reporters";

const stream = run({
  isolation: "none",
  coverage: true,
});

stream.compose(spec).pipe(process.stdout);

dummy.test.js

import { describe, it } from "node:test";
import * as assert from "node:assert";

describe("suite", () => {
  it("works", ()  => {
    assert.ok(true);
  });
});

How often does it reproduce? Is there a required condition?

Always. No.

What is the expected behavior? Why is that the expected behavior?

With isolation: "process" (the default), here's the output:

▶ suite
  ✔ works (0.789789ms)
✔ suite (2.636181ms)
ℹ tests 1
ℹ suites 1
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 77.285385
ℹ start of coverage report
ℹ -----------------------------------------------------------------
ℹ file             | line % | branch % | funcs % | uncovered lines
ℹ -----------------------------------------------------------------
ℹ test             |        |          |         | 
ℹ  dummy.test.js   | 100.00 |   100.00 |  100.00 | 
ℹ -----------------------------------------------------------------
ℹ all files        | 100.00 |   100.00 |  100.00 | 
ℹ -----------------------------------------------------------------
ℹ end of coverage report

What do you see instead?

With isolation: "none", here's the output:

▶ suite
  ✔ works (0.979666ms)
✔ suite (2.172736ms)
ℹ tests 1
ℹ suites 1
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 28.684242
ℹ start of coverage report
ℹ ----------------------------------------------------------
ℹ file      | line % | branch % | funcs % | uncovered lines
ℹ ----------------------------------------------------------
ℹ ----------------------------------------------------------
ℹ all files | 100.00 |   100.00 |  100.00 | 
ℹ ----------------------------------------------------------
ℹ end of coverage report

(empty coverage)

The test stream emits a "test:coverage" event, but it is empty:

[Object: null prototype] {
  nesting: 0,
  summary: [Object: null prototype] {
    workingDirectory: '/home/damien/git/socket.io/tmp',
    files: [],
    totals: [Object: null prototype] {
      totalLineCount: 0,
      totalBranchCount: 0,
      totalFunctionCount: 0,
      coveredLineCount: 0,
      coveredBranchCount: 0,
      coveredFunctionCount: 0,
      coveredLinePercent: 100,
      coveredBranchPercent: 100,
      coveredFunctionPercent: 100
    },
    thresholds: [Object: null prototype] { line: 0, branch: 0, function: 0 }
  }
}

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    test_runnerIssues and PRs related to the test runner subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions