freaktechnik / istanbul-jpm

Istanbul Instrumenter and coverage export for Firefox Add-on SDK extensions tested with JPM
https://www.npmjs.com/package/istanbul-jpm
BSD 3-Clause "New" or "Revised" License
1 stars 2 forks source link

Fails at "readcoverageglobal" task #7

Open Happy-Ferret opened 7 years ago

Happy-Ferret commented 7 years ago

Running grunt test the process fails at readcoverageglobal, pointing out that Warning: 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 with var Instrumenter = require("istanbul-jpm").Instrumenter; added to the top of test/test-index.js.

The Gruntfile.js is the one taken from the README, with the path inside instrument: changed to test/*.js.

freaktechnik commented 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.

Happy-Ferret commented 7 years ago

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.

freaktechnik commented 7 years ago

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.

Happy-Ferret commented 7 years ago

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?

Happy-Ferret commented 7 years ago

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?

freaktechnik commented 7 years ago

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.