Skip to content

Setting "experimental-test-coverage": true within node.config.json causes multiple reports #58828

Closed
@JakobJingleheimer

Description

@JakobJingleheimer

Version

24.3.0

Platform


Subsystem

No response

What steps will reproduce the bug?

  1. Create a node.config.json file and include "experimental-test-coverage": true
  2. in CLI, run node --experimental-config-file='./node.config.json' --test

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

100%

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

It behaves like passing the CLI flag --experimental-test-coverage.

What do you see instead?

It appears the test coverage "flag" from the config file is getting passed along to the various sub-processes the test runner spawns, and they are each reporting their own set of tests' coverage. And then at the end, the parent process reports the full coverage.

Additional information

Merely moving the test coverage flag from config file to cli (leaving other options in the config file) avoids the issue.

node.config.test.json
{
  "$schema": "https://nodejs.org/dist/v24.3.0/docs/node-config-schema.json",
  "nodeOptions": {
    "import": [
      "../../test/snapshots.mts"
    ]
  },
  "testRunner": {
    "experimental-test-coverage": true,
    "experimental-test-module-mocks": true,
    "test-coverage-exclude": [
      "**/test/**",
      "**/*.mock.ts",
      "**/*.test.ts"
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    configIssues or PRs related to the config subsystemconfirmed-bugIssues with confirmed bugs.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions