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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage report not produced with --passWithNoTests flag and no tests #9392

Closed
Soviut opened this issue Jan 10, 2020 · 7 comments
Closed

coverage report not produced with --passWithNoTests flag and no tests #9392

Soviut opened this issue Jan 10, 2020 · 7 comments

Comments

@Soviut
Copy link

Soviut commented Jan 10, 2020

馃悰 Bug Report

We use Coveralls to centralize our test coverage on all our services. New services start with no tests and we use the --passWithNoTests flag for our coverage report step in CircleCI. Which looks like this

jest --coverage --passWithNoTests --runInBand && cat ./coverage/lcov.info | coveralls

We've noticed Coveralls failing because the ./coverage/lcov.info doesn't get created and coveralls fails to parse

No tests found, exiting with code 0
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|
[error] "2020-01-09T15:58:11.526Z"  'error from lcovParse: ' 'Failed to parse string'
[error] "2020-01-09T15:58:11.527Z"  'input: ' ''
[error] "2020-01-09T15:58:11.528Z"  'error from convertLcovToCoveralls'
/home/circleci/project/node_modules/coveralls/bin/coveralls.js:19
      throw err;
      ^
Failed to parse string

To Reproduce

Steps to reproduce the behavior:

Run the following

jest --coverage --passWithNoTests --runInBand && cat ./coverage/lcov.info

No /coverage/lcov.info is produced.

However, with a dummy/stub test it does work and produces the file.

Expected behavior

A valid coverage file would be produced with no tests if the --passWithNoTests flag is set.

@SimenB
Copy link
Member

SimenB commented Apr 8, 2020

Is this a bug in istanbul? @coreyfarrell, seems like a report should be generated even if it's empty? A text report is generated, I'd think an lcov report would also be?

@coreyfarrell
Copy link
Contributor

If I run the following commands from an empty directory:

npm init -y
npm i -D nyc
mkdir .nyc_output
npx nyc report -r lcovonly

This creates a 0 byte coverage/lcov.info file. With no data I'm not sure what the lcov.info is expected to contain? I suspect that from jest coverage/lcov.info is being created, just it's empty and coveralls does not deal with this situation. Maybe coveralls should give a better error like "No coverage received"?

I did some quick experimentation with genhtml (the standard gcc utility for converting lcov.info to html reports). It reported the error genhtml: ERROR: no valid records found in tracefile lcov.info. I'm not sure what can be done with this situation, even manually I was unable to create an lcov file with no data that was accepted by genhtml.

@SimenB
Copy link
Member

SimenB commented Apr 8, 2020

Right, so in theory coveralls should accept an empty file?

@coreyfarrell
Copy link
Contributor

Probably. At minimum it shouldn't say "parse error" it should detect the special case of an empty file. Not sure if it should report to the coveralls server in this case, I'd think yes so that coveralls site can report that no coverage was received rather than just being unaware of that CI run.

@github-actions
Copy link

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 25, 2022
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions
Copy link

github-actions bot commented May 4, 2022

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 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants