-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add documentation/example for coverage with c8
#89
Comments
The whole point of a unix pipeline and the unix philosophy is to split a set of tasks into different specialised processes which communicate by the standard streams (stdout and stdin). In our case that would be a node process (running zora) producing a TAP stream which is piped into a reporting process (tap-difflet here). With the output of c8 into the stdout, you add to the TAP stream some text tap-dfflet can not parse and does not ignore apparently. That is not really related to zora itself but I understand your confusion if you are not familiar with the Unix philosophy. I am not really fond of the code coverage metric but if I had to use it I would rather use a different script to avoid the cost of code instrumentation on every run. You use TS if I am correct. So you can have a look at that gist. Alternatively, you can ask c8 to use a reporter which does not output anything on the stdout: I would let the reporter to each developer so if one wants to use Regarding you second problem. I don't know what your
That be great ! I had started a while back a list of recipes (which might be out of date) which could help you. You might find that article of your interest as well |
I understand the basics of streams and pipes - what wasn't obvious is the fact that The recipe list looks like a good starting point. The TS recipe from the gist probably should be added? And there should be a link to the recipes repo, front-and-center, in the README - probably in the "Installation" section, as this will be the first thing anybody needs in order to get rolling. 🙂 Hmm, looking at this makes me think about building a simple web-based tool which would scaffold the whole |
In your examples, what does the |
Zora uses is to allow the only mode: by default zora throws if it encounters a |
I sank another half-day into this and still no closer to a working project. 😕 I gave your gist a go first, but that didn't work. I don't think this approach is going to work with So I went back to the recipe, but it's not very different from what I had already, and it doesn't work for me.
I'm using node I'm having a little more luck in my own project - it's similar, but I use
This runs, and I thought I had code-coverage set up and working with It seems to have something to do with source-maps. If I switch between inline and external source-maps, I get wildly different results: with inline source-maps, the reporter actually lists my source I'm all out of ideas. Why is every JS tooling experience like this. Nothing should be this hard. I don't think I'm smart enough to solve this. I think I'll just give up and proceed without code-coverage for now. 😑 |
yes, it is always a pain to mix node, typescript, bundler, ES module, commonjs module, etc. I try to stay away of all these unnecessary build steps (doest TS actually help you to ship better code ? ) I am not familiar with many of the tools you are using so I am not sure I can help much. Have you tried nyc for code coverage ? |
On this project, yes - especially on the test side, it's massively better. I will try You understand the recipe didn't run at all, out of the box, right? It's probably outdated with regards to either node or some of the npm dependencies. Why does every JS project seem to fall apart in about a year or so. 😂 |
closed in favor of #50 |
I've been trying to set up
c8
to instrument code-coverage in my zora project.It seems there are plenty of wrong ways to set this up - for example, I intuitively tried this:
This leads to really strange results, as the tap-output from zora gets the default text-report from
c8
appended to the stream, causing thetap-difflet
reporter to report the wrong number of passed/failed tests.I got a little closer with something like this:
In other words, run
c8
with--reporter none
while instrumenting code-coverage, avoiding the garbled tap stream - then runc8
again withreport
to make it pick up the coverage data from the first run. It took a while to figure this out, as the command-line docs forc8
aren't great either.My next problem is, it reports for the test-files themselves (
*.test.ts
) and also forindex.mjs
innode_modules/zora
for some reason - I've tried to control this with the--include
and--exclude
switches, to no avail:It's not clear to me if these switches apply to
c8
instrumentation run, or the reporter run... I tried using the switches withc8 report
instead - adding the--include
switch results in an empty report, while adding the--exclude
switch has no effect at all.Since
c8
is the code-coverage tool you recommend, presumably you've managed this get this working? 🙂Can we have a working example in the README maybe?
Do you have a working project you can point to for reference?
(Stuff like this is very time-consuming and frustrating. Have you thought about making a home page or wiki for zora or something? I'd like to help with documentation. Zora is very much "batteries not included", which I like - but it's really important we can point people to working examples or documentation that is easy to follow.)
The text was updated successfully, but these errors were encountered: