Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jehy opened this issue Feb 11, 2020 · 4 comments · Fixed by #9562
Closed

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

jehy opened this issue Feb 11, 2020 · 4 comments · Fixed by #9562
Labels

Comments

@jehy
Copy link

jehy commented Feb 11, 2020

🐛 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
@jehy
Copy link
Author

jehy commented Feb 11, 2020

UPD. I also tried to remove coverage options from config files, and only provide them via cli.
I get same results as from bad-coverage script.

So it seems that CLI option --coverageProvider v8 behaves differently then config option coverageProvider: 'v8'.

@SimenB
Copy link
Member

SimenB commented Feb 11, 2020

Yeah, only the CLI option works, for some reason the config one doesn't. I'll fix that. As for the broken report, that probably the same as the c8 issue you linked to, yeah

@jehy
Copy link
Author

jehy commented Feb 11, 2020

It's great that it will be fixed!
Concerning broken report - I suppose that it's a bug in Istanbul tools - since both c8 and jest use it for generating reports. I hope someone could point out source of the bug and open an issue - I haven't seen one yet.

UPD. Aded an issue istanbuljs/istanbuljs#527

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants