-
Notifications
You must be signed in to change notification settings - Fork 788
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
Support source maps for html report #59
Comments
That sounds like a lot of work :) I agree that this is very useful. Let me think about this to figure out a solution. |
I would like to understand how you are running your tests with browserify and istanbul in the mix because I suspect that there is no use case for istanbul to consume browserify source maps. Consider this sequence:
Step (4) should still work in the above sequence and give you coverage info w.r.t to the original sources. Now, it may be that istanbul needs additional flags based on your use-case to be able to extract the correct coverage global but that should be an implementation detail which we can work together to fix. Conceptually I do not see the need for istanbul to deal with browserify source maps. Thoughts? |
This is a case of me opening my mouth before exploring all the options available. Instrumenting the code before bundling works great. Thanks @gotwarlost |
@jasonpincin I am trying to set up a similar configuration, istanbul coverage reports on browserified js, but am having trouble. Would you be able to elaborate on your solution? Do you have a working example? |
@tcmitche We use a Makefile along the lines of: bundle:
@istanbul instrument --output lib-cov lib
@ls -1 test/unit | awk '{print "require(\"../unit/"$$1"\")"}' > test/bundle/_unit.js
@browserify --fast --debug test/bundle/_unit.js > test/bundle/unit.js
@rm -f test/bundle/_unit.js
test: bundle
@mocha-phantomjs -R tap test/unit.html You can get a lot fancier, but that's the basics. |
Would love to follow up on this browserify issue. Having to do a The fact that I would love an I'll see if I can build this :) |
I wrote a browserify transform for instanbul here. It works pretty well, especially when combined with karma-coverage for reporting - generates the same HTML output as in Node. |
@gotwarlost you said "there is no use case for istanbul to consume browserify source maps" - there is... :) I compile my TypeScript sources to JS and then execute Mocha tests. Coverage, that I see, is generated for generated JS files. You can take a look on it here: https://github.com/kirill-konshin/typescript |
I vote on re-opening this, for support on languages compiling to js. In my case I write in ECMAScript 6, and have my code transpiled by 6to5; the output code is still readable, yes, but it differs from the original code. Anyway supporting source maps seems easier than supporting every language in the wild. |
@XeCycle +1 |
Just a mere +1 |
+1 |
+1 (though i wouldn't limit this to just html reports) |
@gotwarlost are you seeing these comments? +1 This also related to #308 - you could perhaps be clever and allow code that doesn't map back the input to not be marked as not covered? |
+1 Compiling typescript -> js |
1 similar comment
+1 Compiling typescript -> js |
+1 typescript -> js |
This issue appears to now be covered by #212 |
I was able to map back my coverage reports using source maps (I'm using typescript). Basically I'm just using lcov-sourcemap by Tapad. You'll want to look at files package.json, scripts/map-coverage.js and circle.yml. Here's the final report for .ts files: https://codecov.io/github/urbanmassage/opool |
Here's another great package for dealing with source maps: https://github.com/SitePen/remap-istanbul |
For anyone interested in mapped coverage reports involving:
This may be of help: OutputJasmineSee https://github.com/Izhaki/Typescript-Jasmine-Istanbul-Boilerplate. package.json (the relevant stuff):
MochaSee https://github.com/Izhaki/Typescript-Mocha-Istanbul-Boilerplate. package.json (the relevant stuff):
|
With the 'instrument before bundling' approach, you need to build the project every time you want to get coverage data, even if you only touched the tests. That is sub-optimal as it takes more time and CPU power than just re-running the tests on a built artifact that has a source map (unless the source map processing and line translation takes more time than compiling a project, but that would surprise me). Having something like istanbul-remap builtin would be nice (for me as a user) as it would remove a moving piece of the setup. @gotwarlost: Any chance you could at some point work with the SitePen/Dojo folks to upstream the remap-istanbul core in Istanbul itself? It would solve #212 for all transpiled languages that support source maps (meaning, each and every serious one). Pinging @kitsonk and @jdonaghue as well, upstreaming the core would allow you to ditch the various task runners and pre-processor plugins that you have to maintain. Edit: for one, you use the same license (BSD-3-clause), that's already one hurdle out of the way... |
HTML report should support source maps. This would allow the reports to be far more digestible when running against browserify bundles (https://github.com/substack/node-browserify).
The text was updated successfully, but these errors were encountered: