Closed cagross closed 3 years ago
tape does not offer anything directly; however, it works great with https://npmjs.com/nyc - which then produces reports that codecov, coveralls, etc can consume. I use nyc + tape + codecov on about 250 repos.
OK thanks for that. I had a cursory look at nyc, and its integration with codecov. But I'm still a little unclear on what exactly nyc and codecov do. I think the setup works like this:
Is that a reasonably accurate top level assessment? If not, what am I misunderstanding?
nyc node test/index.js
produces code coverage output, it does this by instrumenting node
, it's test framework agnostic.
nyc report --html
can show you a HTML report on your laptop.
codecov
is a tool that integrates with github & pull requests, it allows you see code coverage HTML report onlines without having to check out the branch yourself and run nyc
to generate a report.
It's not possible for coverage to be computed without instrumenting the environment - jest's coverage works in the same way - and it's a very intrusive thing that's tricky to get right. nyc
does get it right as far as I'm able to tell, and by virtue of that is test-runner agnostic.
OK thanks to both of you. I now understand codecov's role in this. I am still a little unsure on what you mean by nyc
instrumenting Node, and how it can then produce coverage output while being test runner agnostic. But that's probably because I'm just a novice :-) I will close this issue and go read up on that separately.
nyc
instruments a javascript program with counters for code coverage per statement, line and branch.
The idea of code coverage for a test suite is to just run a javascript program ( for example a test suite ) and then to see what code was covered or not.
In theory you can enable code coverage on your application, run your app, click around, close the app and look at the code coverage report of all the clicking you've done.
It's outputting coverage of your application code and you can either drive it manually or let your test suite drive it.
OK thanks for the discussion and explanations. I think I'm starting to get it.
In theory you can enable code coverage on your application, run your app, click around, close the app and look at the code coverage report of all the clicking you've done.
So in my case, what's happening is that nyc would do the following:
Am I understanding that correctly? If so, then cool--I believe I understand things now.
Hello. In my project I’ve created many unit tests with Tape. I’m just now learning about the concept of code coverage, and would like to incorporate such reporting in my development. Does Tape offer a way to report on coverage? I believe the answer is ‘no,’ in-part because the devs want to keep Tape lightweight. If so, no worries—that’s a great reason. But if I wanted to obtain coverage information on my unit tests, what options would I have?
Possibilities
nyc or istanbul packages: I searched through the GitHub issues in this repo and saw previous issues that referenc the nyc package or istanbul package.
codecov package: I noticed that when I submitted my recent pull requests to the Tape repo, something called codecov provided some kind of coverage report. Could codecov be an option for me?
Jest package: Others have suggested using Jest to report on my test coverage. But am I correct that if I want to do that, I have to refactor all my unit tests from Tape to Jest? If so, that seems a bit undesirable right now.
Thanks in advance.