Skip to content
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

Istanbul doesn't play nicely with sandboxed-module #108

Closed
searls opened this issue Oct 16, 2013 · 3 comments
Closed

Istanbul doesn't play nicely with sandboxed-module #108

searls opened this issue Oct 16, 2013 · 3 comments

Comments

@searls
Copy link

searls commented Oct 16, 2013

I require each of my units with sandboxed-module so that I can isolate it from its collaborators, but unfortunately this approach means istanbul never instruments the code that's loaded (and requiring it separately doesn't work either).

More discussion here.

@gotwarlost
Copy link
Owner

Low-tech inelegant solution:

  • Pre-instrument the code using istanbul instrument
  • Ensure that the instrumented version of code is loaded in tests
  • Ensure that the __coverage__ global is set for every sandbox you create so it keeps accumulating stuff
  • Write a process.on('exit') handler to dump coverage to file system (similar to istanbul cover)
  • Run istanbul report to get the reports.

As I said, fugly :)

@searls
Copy link
Author

searls commented Oct 16, 2013

Thanks. I actually have started a really nasty monkey patch in lieu of this. I've got everything working up until the report generation (because, grossly, the sandboxed-module code will be a couple of lines longer than the actual file listing).

https://gist.github.com/searls/7001427

@searls
Copy link
Author

searls commented Oct 16, 2013

Just updated the gist, glad to report that I got this monkey patch of sandboxed-module playing completely nicely with istanbul: https://gist.github.com/searls/7001427

@searls searls closed this as completed Oct 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants