Open Happy-Ferret opened 7 years ago
To instrument files you have to use istanbul on your extension files with the provided instrumenter. Then load the instrumented files in your tests instead of the original files and it will automatically write the json file.
I don't think I quite understand.
Are you saying I should manually run istanbul instrument
on those files? Because I already did that with very little to show for.
Oh. And slightly off-topic: I don't suppose there's a way to create the coverage reports without the inclusion of jpm, is there? It's really kind of bothersome that for all other javascript applications I can just call istanbul cover
but for Firefox extensions and XUL code (I have some js ctypes codebases that I'd love to use xpcshell rather than jpm for) I have to jump through extra hoops.
The reason you need JPM is to run the tests within Firefox. If your tests don't depend on any Firefox infrastructure you don't need to use JPM.
You can use grunt or whatever to instrument, but JPM does not instrument them.
I do depend on Firefox. It's just that not all my code are extensions. Some of it I could just as well run inside xpcshell.
Anyhow. It's still failing.
Could you, perhaps, outline the basic steps following the instantiation of a basic addon via jpm init
?
Aside of installing the node modules (grunt, istanbul-jpm, etc), adding the Gruntfile.js and running grunt test
what else is there to do?
Never mind. After reading your blog post I got it now.
However, the report contains the instrumented version only. Is this how it's supposed to be or do I need to run some sort of source mapping?
The report, once generated with istanul should map the lines back to the original (be it lcov or html). Else there is some path problem with the report generator that can't find the proper source files.
Running
grunt test
the process fails atreadcoverageglobal
, pointing out thatWarning: ENOENT: no such file or directory, open 'C:\msys64\tmp\istanbul-jpm-coverage.json' Use --force to continue.
I'm rather new to jpm so this is, unfortunately, not quite obvious to me.
How do I actually export the
.json
file it's asking for?The extension is just the standard boilerplate code created by
jpm init
withvar Instrumenter = require("istanbul-jpm").Instrumenter;
added to the top oftest/test-index.js
.The
Gruntfile.js
is the one taken from the README, with the path insideinstrument:
changed totest/*.js
.