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

Failed to save coverage (for TypesScript) #79

Closed
deskoh opened this issue Jan 21, 2019 · 14 comments
Closed

Failed to save coverage (for TypesScript) #79

deskoh opened this issue Jan 21, 2019 · 14 comments

Comments

@deskoh
Copy link

deskoh commented Jan 21, 2019

Unable to save report even though tests completed.

Codebase.
Commit: 906dead1e336493ec1cde8653678d68f38bd9de3

I20190121-19:19:12.959(8)?   Hello
I20190121-19:19:12.959(8)?     ✓ should count correctly
I20190121-19:19:12.959(8)?
I20190121-19:19:12.960(8)?   HelloJS
I20190121-19:19:12.960(8)?     ✓ should count correctly
I20190121-19:19:12.961(8)?
I20190121-19:19:12.961(8)?   Info
I20190121-19:19:12.961(8)?     ✓ should render correctly
I20190121-19:19:12.961(8)?
I20190121-19:19:12.962(8)?
I20190121-19:19:12.962(8)?   3 passing (21ms)
I20190121-19:19:12.962(8)?
I20190121-19:19:12.962(8)? Meteor-coverage is saving client side coverage to the server. Client js files saved  {\"SUCCESS\":0,\"FAILED\":0,\"TOTAL\":0}
I20190121-19:19:13.133(8)? All tests finished!
I20190121-19:19:13.134(8)?
I20190121-19:19:13.135(8)? --------------------------------
I20190121-19:19:13.135(8)? SERVER FAILURES: 0
I20190121-19:19:13.136(8)? CLIENT FAILURES: 0
I20190121-19:19:13.136(8)? --------------------------------
W20190121-19:19:13.228(8)? (STDERR) Error: Failed to save lcovonly coverage
W20190121-19:19:13.228(8)? (STDERR)     at HTTP.get (packages/meteortesting:mocha/server.handleCoverage.js:37:18)
W20190121-19:19:13.229(8)? (STDERR)     at runWithEnvironment (packages\meteor.js:1356:24)

Expected Behavior

Coverage report generated.

Possible Solution

Using lmieulet:[email protected] is a partial fix. But static assets will not be generated or are 0 bytes. Furthermore, the packages MUST be in .meteor/packages in the following order: meteortesting:[email protected], jquery, lmieulet:[email protected].

Steps to Reproduce (for bugs)

Note: For linux-based systems, change %CD% to $PWD/ for npm scripts in package.json.

git clone --branch coverage https://github.com/deskoh/Meteor-React-Typescript-Starter.git
git checkout 906dead1e336493ec1cde8653678d68f38bd9de3
cd Meteor-React-Typescript-Starter
meteor npm ci
npm run test:coverage

# Test results visible in browser for following commands
npm run test:watch
npm run test:watch:coverage

However, renaming Info.test.js to Info.tests.js will render HTML coverage results with only Info.tests.js.

Context

Your Environment

  • Version used: Meteor 1.8.0.2
  • Operating System and version: Windows 10 v1809
@serut
Copy link
Owner

serut commented Jan 21, 2019

Hello,

I'm not sure the coverage is working on Windows. Last time I checked it wasn't with meteortesting:mocha and it was not working.

I did not test with Typescript neither. As you can see in the logs, there is no file that has been instrumented on the client side :
I20190121-19:19:12.962(8)? Meteor-coverage is saving client side coverage to the server. Client js files saved {\"SUCCESS\":0,\"FAILED\":0,\"TOTAL\":0}. If you fix that, maybe the lcovonly task will work.

If I get some time, I will try with your repository.

@deskoh
Copy link
Author

deskoh commented Jan 22, 2019

Updated issue.

Had a workaround, see commit.

Browse source.

Essentially, revert to lmieulet:[email protected]. But static assets will not be generated or are 0 bytes. Furthermore, the packages MUST be in .meteor/packages in the following order: meteortesting:[email protected], jquery, lmieulet:[email protected].

@serut
Copy link
Owner

serut commented Jan 22, 2019

Maybe the babel instanbul package is not compatible with the meteor typescript package.
If you get back to the initial commit with meteor-coverage 3.0 and you runs the server with coverage verbose, do you see your server files instrumented ?

@deskoh
Copy link
Author

deskoh commented Jan 23, 2019

Added dummy server test (with empty test body) in /server/main.test.js and got similar results:

=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

I20190123-22:28:58.033(8)?     √ main
I20190123-22:28:58.033(8)?
I20190123-22:28:58.034(8)?
I20190123-22:28:58.034(8)?   1 passing (16ms)
I20190123-22:28:58.035(8)?
I20190123-22:28:58.036(8)?
I20190123-22:28:58.036(8)? --------------------------------
I20190123-22:28:58.037(8)? ----- RUNNING CLIENT TESTS -----
I20190123-22:28:58.037(8)? --------------------------------
[0123/222859.107:ERROR:gpu_process_transport_factory.cc(967)] Lost UI shared context.

DevTools listening on ws://127.0.0.1:58079/devtools/browser/418575e0-1184-452a-ad2f-b4d6908062ba
[0123/222903.617:INFO:CONSOLE(87242)] "%cDownload the React DevTools for a better development experience: https://fb.me/react-devtools", source: http://localhost:3000/packages/modules.js?hash=8f62e041b28e4a67fdef27b1df5da72a6e03f9c6 (87242)
[0123/222903.637:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/222903.638:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
...
[0123/222903.668:INFO:CONSOLE(298)] "Meteor-coverage is saving client side coverage to the server. Client js files saved  {"SUCCESS":0,"FAILED":0,"TOTAL":0}", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
I20190123-22:29:03.677(8)? %cDownload the React DevTools for a better development experience: https://fb.me/react-devtools" "font-weight:bold
I20190123-22:29:03.679(8)?
I20190123-22:29:03.680(8)?
I20190123-22:29:03.681(8)?   Hello
I20190123-22:29:03.682(8)?     ✓ should count correctly
I20190123-22:29:03.683(8)?
I20190123-22:29:03.683(8)?   HelloJS
I20190123-22:29:03.684(8)?     ✓ should count correctly
I20190123-22:29:03.685(8)?
I20190123-22:29:03.686(8)?   Info
I20190123-22:29:03.687(8)?     ✓ should render correctly
I20190123-22:29:03.688(8)?
I20190123-22:29:03.688(8)?
I20190123-22:29:03.689(8)?   3 passing (30ms)
I20190123-22:29:03.690(8)?
I20190123-22:29:03.691(8)? Meteor-coverage is saving client side coverage to the server. Client js files saved  {\"SUCCESS\":0,\"FAILED\":0,\"TOTAL\":0}
I20190123-22:29:03.942(8)? All tests finished!
I20190123-22:29:03.943(8)?
I20190123-22:29:03.944(8)? --------------------------------
I20190123-22:29:03.945(8)? SERVER FAILURES: 0
I20190123-22:29:03.946(8)? CLIENT FAILURES: 0
I20190123-22:29:03.947(8)? --------------------------------
W20190123-22:29:04.075(8)? (STDERR) Error: Failed to save lcovonly coverage
W20190123-22:29:04.076(8)? (STDERR)     at HTTP.get (packages/meteortesting:mocha/server.handleCoverage.js:37:18)
W20190123-22:29:04.078(8)? (STDERR)     at runWithEnvironment (packages\meteor.js:1356:24)

Then tried renaming main.test.js to main.tests.js (Note the additional 's'). Similar to what was observed in original issue, coverage report was generated, but with only main.test.js shown. And of course, the coverage was 100%.

Tried again with main.test.js and convert main.ts to main.js (simply removed the type annotations), similar observations as original issue, no coverage report can be generated.

@serut
Copy link
Owner

serut commented Jan 23, 2019

Sorry, but that's not what I'm expecting. Are you sure you added the COVERAGE_VERBOSE=1 in the running command ? (see this for example)

@deskoh
Copy link
Author

deskoh commented Jan 23, 2019

Here's the output dump with COVERAGE_VERBOSE=1:

[[[[[ Tests ]]]]]

=> Started proxy.
imports/ui/Hello.test.tsx (6, 5): Cannot find name 'Meteor'.
imports/ui/Hello.test.tsx (11, 3): Cannot find name 'before'.
imports/ui/Hello.test.tsx (16, 3): Cannot find name 'describe'.
imports/ui/Hello.test.tsx (18, 5): Cannot find name 'it'.
=> Started MongoDB.
I20190123-23:17:48.654(8)? Coverage active
I20190123-23:17:48.751(8)? Reading custom configuration
I20190123-23:17:48.752(8)? [Configuration]  { remap:
I20190123-23:17:48.753(8)?    { format:
I20190123-23:17:48.754(8)?       [ 'html',
I20190123-23:17:48.754(8)?         'clover',
I20190123-23:17:48.755(8)?         'cobertura',
I20190123-23:17:48.756(8)?         'json',
I20190123-23:17:48.757(8)?         'json-summary',
I20190123-23:17:48.757(8)?         'lcovonly',
I20190123-23:17:48.758(8)?         'teamcity',
I20190123-23:17:48.759(8)?         'text',
I20190123-23:17:48.759(8)?         'text-summary' ] } }
I20190123-23:17:48.760(8)? Loading default configuration: output
I20190123-23:17:48.761(8)? Loading default configuration: remapFormat
I20190123-23:17:48.761(8)? Coverage configuration:
I20190123-23:17:48.763(8)? - IS_COVERAGE_ACTIVE= true
I20190123-23:17:48.763(8)? - IS_COVERAGE_VERBOSE= true
I20190123-23:17:48.764(8)? - COVERAGE_APP_FOLDER= D:\code\web-projects\Meteor-React-Typescript-Starter
I20190123-23:17:48.765(8)? .coverage.json values:
I20190123-23:17:48.766(8)? - remapFormat= [ 'html',
I20190123-23:17:48.767(8)?   'cobertura',
I20190123-23:17:48.772(8)?   'clover',
I20190123-23:17:48.773(8)?   'json',
I20190123-23:17:48.774(8)?   'json-summary',
I20190123-23:17:48.775(8)?   'lcovonly',
I20190123-23:17:48.775(8)?   'teamcity',
I20190123-23:17:48.776(8)?   'text',
I20190123-23:17:48.777(8)?   'text-summary' ]
I20190123-23:17:48.778(8)? - COVERAGE_EXPORT_FOLDER= ./.coverage
I20190123-23:17:50.802(8)?
I20190123-23:17:50.803(8)? --------------------------------
I20190123-23:17:50.804(8)? ----- RUNNING SERVER TESTS -----
I20190123-23:17:50.805(8)? --------------------------------
I20190123-23:17:50.806(8)?
I20190123-23:17:50.807(8)?
I20190123-23:17:50.808(8)?
I20190123-23:17:50.815(8)?   Server Test
=> Started your app.

=> App running at: http://localhost:3000/
   Type Control-C twice to stop.

I20190123-23:17:50.832(8)?     √ main
I20190123-23:17:50.834(8)?
I20190123-23:17:50.834(8)?
I20190123-23:17:50.835(8)?   1 passing (29ms)
I20190123-23:17:50.836(8)?
I20190123-23:17:50.837(8)?
I20190123-23:17:50.837(8)? --------------------------------
I20190123-23:17:50.838(8)? ----- RUNNING CLIENT TESTS -----
I20190123-23:17:50.839(8)? --------------------------------
[0123/231752.096:ERROR:gpu_process_transport_factory.cc(967)] Lost UI shared context.

DevTools listening on ws://127.0.0.1:50497/devtools/browser/a389eb3d-0682-44e6-8848-0e312cb6779f
[0123/231756.752:INFO:CONSOLE(87242)] "%cDownload the React DevTools for a better development experience: https://fb.me/react-devtools", source: http://localhost:3000/packages/modules.js?hash=8f62e041b28e4a67fdef27b1df5da72a6e03f9c6 (87242)
[0123/231756.777:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.779:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.784:INFO:CONSOLE(298)] "  Hello", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.807:INFO:CONSOLE(298)] "    Ô£ô should count correctly", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.808:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.809:INFO:CONSOLE(298)] "  HelloJS", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.812:INFO:CONSOLE(298)] "    Ô£ô should count correctly", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.812:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.813:INFO:CONSOLE(298)] "  Info", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.819:INFO:CONSOLE(298)] "    Ô£ô should render correctly", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.820:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.822:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.822:INFO:CONSOLE(298)] "  3 passing (48ms)", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.823:INFO:CONSOLE(298)] "", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
[0123/231756.824:INFO:CONSOLE(298)] "Meteor-coverage is saving client side coverage to the server. Client js files saved  {"SUCCESS":0,"FAILED":0,"TOTAL":0}", source: http://localhost:3000/packages/meteortesting_mocha.js?hash=c5cccedbb0c81b30c86f4559436a7c8b9dc202c1 (298)
I20190123-23:17:56.826(8)? %cDownload the React DevTools for a better development experience: https://fb.me/react-devtools" "font-weight:bold
I20190123-23:17:56.827(8)?
I20190123-23:17:56.829(8)?
I20190123-23:17:56.829(8)?   Hello
I20190123-23:17:56.831(8)?     ✓ should count correctly
I20190123-23:17:56.832(8)?
I20190123-23:17:56.832(8)?   HelloJS
I20190123-23:17:56.833(8)?     ✓ should count correctly
I20190123-23:17:56.834(8)?
I20190123-23:17:56.835(8)?   Info
I20190123-23:17:56.839(8)?     ✓ should render correctly
I20190123-23:17:56.840(8)?
I20190123-23:17:56.840(8)?
I20190123-23:17:56.841(8)?   3 passing (48ms)
I20190123-23:17:56.842(8)?
I20190123-23:17:56.843(8)? Meteor-coverage is saving client side coverage to the server. Client js files saved  {\"SUCCESS\":0,\"FAILED\":0,\"TOTAL\":0}
I20190123-23:17:57.080(8)? All tests finished!
I20190123-23:17:57.082(8)?
I20190123-23:17:57.083(8)? --------------------------------
I20190123-23:17:57.084(8)? SERVER FAILURES: 0
I20190123-23:17:57.085(8)? CLIENT FAILURES: 0
I20190123-23:17:57.085(8)? --------------------------------
I20190123-23:17:57.086(8)? Export code coverage
I20190123-23:17:57.088(8)? - Out lcovonly
I20190123-23:17:57.153(8)? export coverage using the following format [ lcovonly ] options [ { path: 'D:\\code\\web-projects\\Meteor-React-Typescript-Starter\\.coverage',
I20190123-23:17:57.154(8)?   verbose: true } ]
I20190123-23:17:57.157(8)? Try to remove the content & create the file D:\code\web-projects\Meteor-React-Typescript-Starter\.coverage\lcov.info
W20190123-23:17:57.231(8)? (STDERR) Error: Failed to save lcovonly coverage
W20190123-23:17:57.233(8)? (STDERR)     at HTTP.get (packages/meteortesting:mocha/server.handleCoverage.js:37:18)
W20190123-23:17:57.235(8)? (STDERR)     at runWithEnvironment (packages\meteor.js:1356:24)

@serut
Copy link
Owner

serut commented Jan 23, 2019

Ok there is no clue about what is failing...

If you run it in watch mode + coverage verbose, then open the test app (localhost:3000).
Then open the source of that page, if you download the bundle of your client side code (localhost:3000/Meteor-React-Typescript-Starter.js or something recognizable), you should see in the server console that the file have been instrumented and the code itself instrumented (in your browser).

Then if you do the same with the react app from my example repository, do you see the code instrumented ?

I hope you get what I mean... ;)

@deskoh
Copy link
Author

deskoh commented Feb 6, 2019

After starting test in watch mode. Server console output stops at:

I20190206-18:20:35.741(8)? Load the app in a browser to run client tests, or set the TEST_BROWSER_DRIVER environment variable. See https://github.com/meteortesting/meteor-mocha/blob/master/README.md#run-app-tests

When viewing source, all except 2 bundle scripts are in /app directory, namely /app/global-imports.js?hash=... and /app/app.js?hash=xxx. The rest of bundles are from /packages directory. However, viewing those sources does not produce further console output.

Interestingly, the server tests only shows in serve console output but not in browser.

@serut
Copy link
Owner

serut commented Feb 9, 2019

As there is no plan to officially support Meteor + Typescript + babel together (see this), the current version of meteor-coverage does not receive any coverage information about your source app. That's why my library is active but there is no coverage to export.
I've just tested your app with the [email protected]. It just hook the meteor build process to cover files before executing them and the current version of meteor-coverage still generates reports.
And it works on my side... Can you give it a try ? https://github.com/serut/meteor-coverage-app-exemple/tree/master/Meteor-React-Typescript-Starter it just need to clean that, maybe rename meteor-packages-coverage but it will be fine.

@deskoh
Copy link
Author

deskoh commented Feb 9, 2019

Looks good! Will do more extensive tests over next few weeks and report back.

@deskoh
Copy link
Author

deskoh commented Feb 12, 2019

So far testing on another project works for both TS and JS files. So the meteor-coverage package will be published with the TS fix soon?

@serut
Copy link
Owner

serut commented Feb 21, 2019

Everything have been published ! If you encounter any problem, feels free to open again this issue or create another one ! ;)

@serut serut closed this as completed Feb 21, 2019
@Gobliins
Copy link

Gobliins commented Oct 22, 2020

I have the same issue as TC even not on typescript:

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

i do my call with
COVERAGE_OUT_JSON=1 COVERAGE_VERBOSE=1 COVERAGE=1 COVERAGE_APP_FOLDER=$PWD meteor test --extra-packages lmieulet:meteor-coverage

@jankapunkt
Copy link
Collaborator

@Gobliins the fix for me was to never use relative paths, always replace './' with $(pwd)/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants