Skip to content

Is it possible to collect test coverage with node:test and esm-loaders like tsimp? #5071

Closed
@krutoo

Description

@krutoo

Node.js Version

v24.1.0

NPM Version

11.3.0

Operating System

Darwin MSK-G4LQ6YF03T.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6030 arm64

Subsystem

Other

Description

Hi, in my small project I use native Node.js testing features and also tsimp to support TypeScript with type checking during compilation

I am also use setup script to apply happy-dom to my test environment

I am running my tests like this:

node --import tsimp/import --import ./scripts/setup-tests.ts --experimental-test-coverage --test ./src/**/*.test.{ts,tsx}

Apparently according to resulting coverage table the resulting lines after compilation are checked, not the source code lines

It is possible to correctly collect test coverage for source lines not for compiled lines?

Minimal Reproduction

No response

Output

No response

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions