run-with-cover should hook to `vm.runInThisContext` and `vm.hookCreateScript` as well#23

Labels

Milestone

Assignee

2 participants

RequireJS uses vm.runInThisContext to evaluate the AMD modules when running on node.js. I think the cover command should add hooks to runInThisContext and createScript automatically or at least have an easy way to set it.

Since transformFn isn't exposed to other modules I ended up editing istanbul/lib/hook.js directly. Not the most elegant solution but worked on my scenario (loading specs and source code with RequireJS):

@gotwarlost I'm not blocked, moved on to other tasks. In fact it was very easy easy to make it work, took me under 30min. I thought it was going to be impossible or that I would need to call all the coverage methods manually - which seems to require a lot of boilerplate.

Istanbul is a very nice project and it already helped me to find issues on my own code. Keep the good work. Cheers.