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

test:cover results in "No coverage information was collected, exit without writing coverage information" #245

Closed
dan-turner opened this issue Aug 25, 2016 · 32 comments

Comments

@dan-turner
Copy link

Node version:
6.3.0
npm version:
3.10.3
Operating system:
OSX
Command line used:
zsh
Steps to reproduce:
npm run test:cover

@coryhouse
Copy link
Owner

Can you try on the native Mac terminal? Runs fine for me there.

@Mardaneus86
Copy link

Mardaneus86 commented Aug 25, 2016

Same issue here. When running on the native Mac terminal it gives no coverage information. However if I change the path to _mocha from /node_modules/mocha/bin/_mocha to just _mocha it does give coverage information.

Running the same on a windows machine (through VSTS, Visual Studio Team Service builds), it gives no coverage information either with the /node_modules/mocha/bin/_mocha path, but even crashes when I try just the _mocha part (as stated in the comments of PR #246).

So it seems the issue is not with the path to _mocha?

@kwelch
Copy link
Collaborator

kwelch commented Aug 25, 2016

Shouldn't node_modules, have a ./ before it?

@Mardaneus86
Copy link

Mardaneus86 commented Aug 25, 2016

Made a mistake, it's node_modules/mocha/bin/_mocha, not /node_modules/mocha/bin/_mocha like I said in the previous comment. However, I don't think it's related to this specific part, but unsure what's causing it.

The test:cover:travis script is working, only difference with test:cover is that it just adds _mocha without the node_modules prefix.

@kwelch
Copy link
Collaborator

kwelch commented Aug 25, 2016

Right, does switching it to ./node_modules/mocha/bin/_mocha fix anything

@Mardaneus86
Copy link

Negative. It doesn't break anything either, but still no coverage output.

@dan-turner dan-turner changed the title test:cover resulting in "No coverage information was collected, exit without writing coverage information" test:cover results in "No coverage information was collected, exit without writing coverage information" Aug 26, 2016
@markau
Copy link

markau commented Aug 29, 2016

I assume you have unit tests defined? Sorry for the obvious question. remove-demo leaves only an empty placeholder emptyTest.spec.js.

@Mardaneus86
Copy link

In my case, yes, I do have unit tests defined.

@Mardaneus86
Copy link

Just did a clone of this project so I could check if it was related to my own project, but still getting the same result:

$ npm run test:cover

> react-slingshot@5.0.0 test:cover /Users/tim/Projects/react-sling-cover-test
> babel-node node_modules/isparta/bin/isparta cover --root src --report html node_modules/mocha/bin/_mocha -- --require ./tools/testSetup.js "src/**/*.spec.js" --reporter progress


  [▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬]

  54 passing (125ms)

No coverage information was collected, exit without writing coverage information

Really wondering what's the difference between node_modules/mocha/bin/_mocha and _mocha because that creates the following output, but it fails on Windows:

$ npm run test:cover

> react-slingshot@5.0.0 test:cover /Users/tim/Projects/react-sling-cover-test
> babel-node node_modules/isparta/bin/isparta cover --root src --report html _mocha -- --require ./tools/testSetup.js "src/**/*.spec.js" --reporter progress


  [▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬]

  54 passing (105ms)

================================================================================
Writing coverage object [/Users/tim/Projects/react-sling-cover-test/coverage/coverage.json]
Writing coverage reports at [/Users/tim/Projects/react-sling-cover-test/coverage]
================================================================================

=============================== Coverage summary ===============================
Statements   : 99.11% ( 779/786 ), 52 ignored
Branches     : 97.63% ( 247/253 ), 68 ignored
Functions    : 91.49% ( 172/188 ), 7 ignored
Lines        : 98.64% ( 509/516 )
================================================================================

@techanvil
Copy link

techanvil commented Sep 8, 2016

Just chiming in to say I am also experiencing this problem. Same version of Node/NPM as OP, running on Windows 10. I have just tested on a freshly pulled master.

If anyone has an old install which is working could you paste a snapshot of your installed node_modules versions?

@ArcanisCz
Copy link
Contributor

It seems it broke with istanbul 0.4.5
douglasduteil/isparta#123
douglasduteil/isparta#126

I had similar problem on windows as you guys describe, and installing (--save-dev) istanbul 0.4.4 worked for me.

@techanvil
Copy link

Nice one @ArcanisCz, that works a treat!

@coryhouse
Copy link
Owner

Great find @ArcanisCz !

Hrmm, now question is, how can I fix this for everyone? Istanbul is not a direct dependency since Isparta merely uses it behind the scenes. So I believe we have to wait until either Isparta changes their reference or Istanbul fixes the bug.

And in other news, I'm strongly considering moving the project to Jest since it includes this built in and is generally now considered the best option for React dev.

@kwelch
Copy link
Collaborator

kwelch commented Sep 15, 2016

@coryhouse I am very interested in giving jest a try. Let me know if you want me to take a first pass on this?

@Mardaneus86
Copy link

Setting the istanbul dev-dependency to 0.4.4 explicitly fixes the issue. @coryhouse: this might be a temporary fix for users of this project.

I'm also interested in seeing jest integrated.

@coryhouse
Copy link
Owner

@kwelch I'd love to see a PR on Jest! 👍

I'm eager to try it but have read enough to know it sounds like a slam dunk now.

@oshalygin
Copy link
Contributor

+1 for you guys helping solve the issue and +2 for Jest. Possible Pluralsight vid on Jest in the future @coryhouse ? You talked about it quite a bit in the redux one but at that time it was still wonky 🗡

@michaeljonathanblack
Copy link
Contributor

michaeljonathanblack commented Jan 24, 2017

I am not able to see even the absent output. When I run npm run test:cover I run into an ELIFECYCLE error.

> babel-node node_modules/isparta/bin/isparta cover --root src --report html node_modules/mocha/bin/_mocha -- --require ./tools/testSetup.js "./{,!(node_modules)/**/}*.spec.js" --reporter progress


npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/mherodev/.nvm/versions/node/v6.9.2/bin/node" "/Users/mherodev/.nvm/versions/node/v6.9.2/bin/npm" "run" "test:cover"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE

@ericcastro92
Copy link

I've been running in to the same ELIFECYCLE error as mherodev, is there any fix for this?

@coryhouse
Copy link
Owner

I am using Jest in my new course @oshalygin. I've lost patience with trying to keep code coverage working with Mocha. It just seems to be a house of cards. I'd like to move Slingshot to Jest since it has a much simpler config story, snapshot tests, and code coverage built in. I'd welcome a PR from anyone willing.

@nickytonline
Copy link
Collaborator

@kwelch, I guess that means you'll be looking at merging your Jest PR?

@michaeljonathanblack
Copy link
Contributor

I was able to get coverage working in my own fork by making the istanbul version change, targeting mocha, updating istanbul.yml to exclude appropriate files and... maybe some other magic?

I'll see if I can get it working within this repository later tonight. Sorry for the wait.

If the migration to Jest isn't huge, I'd love to make it myself.

@kwelch
Copy link
Collaborator

kwelch commented Jan 25, 2017

@nickytonline I am looking to carve out time this week to wrapping that up. The tests run successfully, but output is still excessive and I have not touched coverage.

The branch is directly on this repo so PRs/commits to that branch are welcome with anything that will move the needle forward.

@nickytonline
Copy link
Collaborator

@kwelch cool beans. I have some free time this weekend, so I'll take a peek at the branch then.

@michaeljonathanblack
Copy link
Contributor

I have a fix for the test coverage, but I can't seem to push to this repository.

mherold-mac:react-slingshot mherold$ git push
ERROR: Permission to coryhouse/react-slingshot.git denied to mherodev.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I made a fresh SSH key, pulled the repository, and it seems fine... outside of not being able to push, e.g.

Hi mherodev! You've successfully authenticated, but GitHub does not provide shell access.

@coryhouse
Copy link
Owner

coryhouse commented Jan 25, 2017 via email

@kwelch
Copy link
Collaborator

kwelch commented Jan 25, 2017

@mherodev There is a good egghead video by @kentcdodds if this is your first PR. 👍

@michaeljonathanblack
Copy link
Contributor

michaeljonathanblack commented Jan 25, 2017

I've committed thousands of PRs professionally, but this would likely be my first open source contribution 💃

For some reason, I cannot submit a new branch to this repository.

ERROR: Permission to coryhouse/react-slingshot.git denied to mherodev.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I'll see if that egghead video has any insight. In the mean time, should I not be using the ssh path to clone and push? I cleared out my ssh keys, generated a new one and added it to GitHub, but no dice.

Also, odd that it says could not read... I just cloned you, repo!

@kentcdodds
Copy link

You'll need to fork the repo. You'll learn about that in the course :)

@michaeljonathanblack
Copy link
Contributor

michaeljonathanblack commented Jan 25, 2017

Oh good, I'm glad I was doing it wrong. whew!

Edit: And hey Kent! Thanks for the video 💯

@michaeljonathanblack
Copy link
Contributor

michaeljonathanblack commented Jan 25, 2017

Got 'em: #358

Thanks for your help @kentcdodds, and @kwelch for the link.

@kwelch
Copy link
Collaborator

kwelch commented Feb 3, 2017

Closing this with the merge of #358.

Any further issues with test coverage, please refer to #223 or create a new issue. Thanks.

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