Skip to content

JSON test report should include coverageMap #4276

@rlaferla

Description

@rlaferla

Describe the bug

vitest should include the coverage map in the coverage report but instead puts them in separate files.

The report should contain a key for the coverage map

e.g.

vitest run --coverage --outputFile=report.json --reporter=json

"coverageMap": {
  "/src/test.ts": {
    "path": "/src/test.ts",
    "statementMap": {
       "0": {
         "start": {
           "line": 1,
           "column": 0
         },
         "end": {
           "line": 1,
           "column": 44
         }
       }
    }
  }
}

Instead it puts the coverage map in a separate file:

coverage/coverage-final.json

Reproduction

If you run:

`% vitest run --coverage --outputFile=report.json --reporter=json

Both of these searches will not return any results:

% grep coverageMap report.json
% grep statementMap report.json

while this will return a result indicating that the json file is the coverage map.

% grep statementMap coverage/coverage-final.json

System Info

System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M2
    Memory: 685.72 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.1 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 116.1.57.47
    Chrome: 117.0.5938.149
    Safari: 17.0
  npmPackages:
    @vitest/coverage-v8: ^0.34.6 => 0.34.6 
    vite: ^4.4.11 => 4.4.11 
    vitest: ^0.34.6 => 0.34.6

Used Package Manager

npm

Validations

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