meteor-coverage icon indicating copy to clipboard operation
meteor-coverage copied to clipboard

No coverage information has been collected

Open YasinY opened this issue 4 years ago • 29 comments

"No coverage information has been collected" despite server tests passing as well as client tests passing when opening the browser, when going on localhost:3000/coverage.

i followed the guide thoroughly, adding all required packages, defining the babel env in package.json as well as setting up the proper run scripts.

Your Environment

  • Version used: latest
  • Environment name and version (e.g. Node 0.10.47): MeteorJS 2.0
  • Operating System and version: MacOS Catalina 10.15

YasinY avatar Jul 08 '21 08:07 YasinY

edit: Error: Failed to save html report at packages/meteortesting:mocha/server.handleCoverage.js:37:18 at runWithEnvironment (packages/meteor.js:1286:24)

is the error. will look into it.

YasinY avatar Jul 08 '21 09:07 YasinY

I don't think meteor-coverage is still working, as I can see the test from the package are not working anymore :

$  meteor npm install
...
$  meteor npm test
...
20210714-13:57:16.986(2)? Creating a new folder /Users/lmieulet/meteor-workspace/meteor-coverage/someapp/.coverage/.remap
W20210714-13:57:17.429(2)? (STDERR) events.js:352
W20210714-13:57:17.430(2)? (STDERR)       throw er; // Unhandled 'error' event
W20210714-13:57:17.430(2)? (STDERR)       ^
W20210714-13:57:17.430(2)? (STDERR) 
W20210714-13:57:17.431(2)? (STDERR) Error [ERR_STREAM_WRITE_AFTER_END] [ERR_STREAM_WRITE_AFTER_END]: write after end
W20210714-13:57:17.431(2)? (STDERR)     at writeAfterEnd (_http_outgoing.js:694:15)
W20210714-13:57:17.431(2)? (STDERR)     at ServerResponse.end (_http_outgoing.js:815:7)
W20210714-13:57:17.431(2)? (STDERR)     at Object.generate (/private/var/folders/0f/j84qkclx6rs160p6yr3d5g8h0000gn/T/meteor-test-run1p922p0.dy2h/.meteor/local/build/programs/server/packages/lmieulet_meteor-coverage.js:1:118215)
W20210714-13:57:17.432(2)? (STDERR)     at Object.generateReport (/private/var/folders/0f/j84qkclx6rs160p6yr3d5g8h0000gn/T/meteor-test-run1p922p0.dy2h/.meteor/local/build/programs/server/packages/lmieulet_meteor-coverage.js:1:121363)
W20210714-13:57:17.432(2)? (STDERR)     at Object.exportFile (/private/var/folders/0f/j84qkclx6rs160p6yr3d5g8h0000gn/T/meteor-test-run1p922p0.dy2h/.meteor/local/build/programs/server/packages/lmieulet_meteor-coverage.js:1:89073)
W20210714-13:57:17.432(2)? (STDERR)     at /private/var/folders/0f/j84qkclx6rs160p6yr3d5g8h0000gn/T/meteor-test-run1p922p0.dy2h/.meteor/local/build/programs/server/packages/lmieulet_meteor-coverage.js:1:93514
W20210714-13:57:17.432(2)? (STDERR)     at /private/var/folders/0f/j84qkclx6rs160p6yr3d5g8h0000gn/T/meteor-test-run1p922p0.dy2h/.meteor/local/build/programs/server/packages/lmieulet_meteor-coverage.js:1:92529
W20210714-13:57:17.432(2)? (STDERR)     at /Users/lmieulet/.meteor/packages/promise/.0.12.0.qsgjpe.bwik++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40
W20210714-13:57:17.433(2)? (STDERR) Emitted 'error' event on ServerResponse instance at:
W20210714-13:57:17.433(2)? (STDERR)     at writeAfterEndNT (_http_outgoing.js:753:7)
W20210714-13:57:17.433(2)? (STDERR)     at processTicksAndRejections (internal/process/task_queues.js:83:21) {
W20210714-13:57:17.433(2)? (STDERR)   code: 'ERR_STREAM_WRITE_AFTER_END'
W20210714-13:57:17.434(2)? (STDERR) }

Coverage folder has been created but no line coverage is visible.

serut avatar Jul 14 '21 12:07 serut

I'm getting a dependency version conflict with meteortesting:[email protected] and lmieulet:[email protected] because version 4.0.0 isn't mentioned in meteortesting:mocha's dependencies: api.use('lmieulet:[email protected] || 2.0.1 || 3.0.0', 'client', { weak: true });

This seems to force meteortesting:mocha to downgrade to version 0.5.1, because it's the last version without an dependency on lmieulet:meteor-coverage

I already created an issue: https://github.com/Meteor-Community-Packages/meteor-mocha/issues/121

bessw avatar Aug 24 '21 01:08 bessw

I create a PR in a few minutes, until it's published you can hotfix this in your .meteor/packages by using

lmieulet:[email protected]!

jankapunkt avatar Aug 24 '21 09:08 jankapunkt

It seems to not fix the situation, I cloned and updated meteortesting:mocha with the following line:

api.use('lmieulet:[email protected] || 2.0.1 || 3.0.0 || 4.0.0', 'client', { weak: true });

and it now runs through but the generated coverage contains only empty lines!

jankapunkt avatar Aug 24 '21 09:08 jankapunkt

Downgrading to lmieulet:[email protected] @serut do you know which changes could be the cause here?

jankapunkt avatar Aug 24 '21 09:08 jankapunkt

It would be cool if that fixes meteor-coverage tests

serut avatar Aug 24 '21 10:08 serut

@serut from my end it works with meteortesting:[email protected] and lmieulet:[email protected] I just wonder why coverage is empty when using 4.0.0 :-/ I also saw that circle tests fail for the latest PR

jankapunkt avatar Aug 24 '21 10:08 jankapunkt

I assume lmieulet:[email protected] uses Meteor 1.8, whereas 4.0.0 uses the latest one. So it can be related to the update of node

serut avatar Aug 24 '21 11:08 serut

Hm but how can this change lead to empty coverage? Isn't it relying on Istanbul?

jankapunkt avatar Aug 24 '21 11:08 jankapunkt

Im not sure which plugin versions were selected, but with meteor 2.3.4 I'm getting this error in my CI:

/<username>/.meteor/packages/meteortesting_mocha-core/.8.1.2.7kamy4.2ci9x++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/mocha/lib/runner.js:906
throw err;
     ^
 
 Error [ERR_STREAM_WRITE_AFTER_END] [ERR_STREAM_WRITE_AFTER_END]: write after end
     at writeAfterEnd (_http_outgoing.js:694:15)
     at ServerResponse.end (_http_outgoing.js:815:7)
     at Object.generate (packages/lmieulet:meteor-coverage/server/report/report-remap.js:59:14)
     at Object.generateReport (packages/lmieulet:meteor-coverage/server/report/report-service.js:28:21)
     at Object.exportFile (packages/lmieulet:meteor-coverage/server/handlers.js:75:19)
     at packages/lmieulet:meteor-coverage/server/router.js:53:16
     at packages/lmieulet:meteor-coverage/server/router.js:26:19
     at /<username>/.meteor/packages/promise/.0.12.0.tdh9wz.ki37p++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:43:40
 Emitted 'error' event on ServerResponse instance at:
     at writeAfterEndNT (_http_outgoing.js:753:7)
     at processTicksAndRejections (internal/process/task_queues.js:83:21) {
   code: 'ERR_STREAM_WRITE_AFTER_END'
 }

bessw avatar Aug 24 '21 12:08 bessw

Hm but how can this change lead to empty coverage? Isn't it relying on Istanbul?

Yes most of the job is packaged with babel / istanbul. But the remap with the sourcemap is done manually, maybe the interface changed with a newest version of node. Not sure yet

Yeap, same error than tests on circle ci https://app.circleci.com/pipelines/github/serut/meteor-coverage/2/workflows/f60aec25-80af-4ff0-843e-8a3572baeba8/jobs/164

serut avatar Aug 24 '21 12:08 serut

Meteor v2.3 updates node from 12.22.1 to 14.17.1

From the node release notes https://nodejs.org/en/blog/release/v14.0.0/ :

  • [c776a37791] - (SEMVER-MAJOR) http: end with data can cause write after end (Robert Nagy) #28666

From #28666:

Calling end() with data while ending should trigger a write after end error.

ERR_STREAM_WRITE_AFTER_END is related to that change.

Could it be that this causes the problems?

bessw avatar Sep 23 '21 19:09 bessw

There is a duplicate call to this.res.end('{"type":"success"}'); First in https://github.com/serut/meteor-coverage/blob/da59c18331807069e49465e27b1c3e072159f467/server/report/report-generic.js#L33

and later in https://github.com/serut/meteor-coverage/blob/da59c18331807069e49465e27b1c3e072159f467/server/report/report-remap.js#L59

I think the second one is redundant, removing this line should fix the error from above, but I can't test it right now.

bessw avatar Oct 02 '21 14:10 bessw

It looks way better without this second call :
https://github.com/serut/meteor-coverage/blob/da59c18331807069e49465e27b1c3e072159f467/server/report/report-remap.js#L59

I've published lmieulet:[email protected], can you try it?

The HTML report does not look functionnal, but text report OK. Let's see if the circle.ci of this package is fine too.

serut avatar Oct 04 '21 12:10 serut

Thanks this fixed my CI jobs with code coverage.

HTML reports are also functional.

bessw avatar Oct 15 '21 19:10 bessw

I still get no coverage, it's all empty (although the files are listed).

I am using 4.1.0 and I get the following messages:

W20211101-13:03:51.286(1)? (STDERR) Handlebars: Access has been denied to resolve the property "statements" because it is not an "own property" of its parent.
W20211101-13:03:51.286(1)? (STDERR) You can add a runtime option to disable the check or this warning:
W20211101-13:03:51.286(1)? (STDERR) See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details

the other packages are

meteortesting:[email protected]
meteortesting:[email protected]
meteortesting:[email protected]

Any ideas?

jankapunkt avatar Nov 01 '21 12:11 jankapunkt

interesting: text summary and json summary do work fine with the above mentioned setup

jankapunkt avatar Nov 01 '21 13:11 jankapunkt

Ok so you don't have lcov and or html coverage report ? May I ask you a reproductible env ?

serut avatar Nov 04 '21 21:11 serut

https://github.com/jankapunkt/meteor-2.5-coverage-issue

jankapunkt avatar Nov 18 '21 10:11 jankapunkt

@serut had no time before but the link contains a repro, although this one is even different, no coverage created at all. However, it's Meteor 2.5 and uses meteortesting:[email protected] and lmieulet:[email protected]

jankapunkt avatar Nov 18 '21 11:11 jankapunkt

@serut any update on this?

jankapunkt avatar Nov 24 '21 15:11 jankapunkt

No time yet to work on this

serut avatar Nov 24 '21 15:11 serut

It can be broken down to the line onSummary in the html report class this is where the errors are generated.

https://github.com/serut/meteor-coverage/blob/master/server/report/report-html.js#L63

jankapunkt avatar Nov 24 '21 15:11 jankapunkt

Downgrading to 3.2.0 fixes the issue

jankapunkt avatar Dec 08 '21 09:12 jankapunkt

it works with

[email protected]
meteortesting:[email protected]
lmieulet:[email protected]
lmieulet:[email protected]

lmieulet:meteor-legacy-coverage is required because im using Typescript, but maybe it's also the reason why coverage is working in my setup.

bessw avatar Dec 08 '21 11:12 bessw

I am also experiencing this problem. I was unable to resolve this by downgrading to 3.2.0 either.

djlogan2 avatar Feb 07 '22 15:02 djlogan2

I am also unable to see any test results. I am testing a newly generated app and package in Meteor 2.6. The versions are the same as bessw lists above. When I run once (like for a CI), OUT_HTML and OUT_JSON both show the "Failed to save XYZ" message. OUT_TEXT "works" because there is no error, but there is no report either.

dreich-nucleus avatar May 04 '22 14:05 dreich-nucleus

Meteor version -> [email protected] meteortesting:[email protected] lmieulet:[email protected]

this works for me

ShubhamKapoorGlider avatar Dec 19 '22 07:12 ShubhamKapoorGlider