Skip to content

Wrong behavior with CLI option coverageProvider v8 and broken cobertura report #9561

Closed
@jehy

Description

@jehy

🐛 Bug Report

In my jest config file, I have

	coverageProvider: 'v8',
	testEnvironment: 'node',
	collectCoverage: true,
	coverageReporters: ['cobertura'],

and all seems fine. But if I add CLI flag --coverageProvider v8 then I get completely another coverage file with <method name="map.<computed>.f" hits="1" signature="()V"> in there - and cobertura can't parse it because < is not allowed in method name.
It only happens on node 12 and 13.

To Reproduce

Steps to reproduce the behavior:

I added a sample repo https://github.com/jehy/jest-coverage-bug
There are two scripts


  "scripts": {
    "good-coverage": "./node_modules/.bin/jest --config jest.config.js --coverageDirectory coverage-good",
    "bad-coverage": "./node_modules/.bin/jest --config jest.config.js --coverageDirectory coverage-bad --coverageProvider v8"
  },

Those should make same output, but good-coverage is fine, and bad-coverage provides completely different coverage file with invalid method name.

See generated bad file here:
https://github.com/jehy/jest-coverage-bug/blob/master/coverage-bad/cobertura-coverage.xml
And good file here:
https://github.com/jehy/jest-coverage-bug/blob/master/coverage-good/cobertura-coverage.xml

Possibly related issue: bcoe/c8#149

Expected behavior

I expect that coverage files would be same and that cobertura will be able to read it (it won't contain < in method name).

Link to repl or repo (highly encouraged)

I described reproduction and link to repo in Reproduce section.

envinfo

  System:
    OS: Linux 5.3 Ubuntu 19.10 (Eoan Ermine)
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
  Binaries:
    Node: 13.8.0 - ~/.nvm/versions/node/v13.8.0/bin/node
    npm: 6.13.6 - ~/.nvm/versions/node/v13.8.0/bin/npm
  npmPackages:
    jest: ^25.1.0 => 25.1.0

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