We are using karma-coverage that runs istanbul and we noticed annoying thing that outputs the js.html files to wrong places. Worst part was that due to this path issue it overwrote our own application index.html file with test result index.html. We are using Webpack, Babel 6.x and Angular in the project.
I investigated issue a bit and noticed that writeFiles in html reporter is writing output files to same place where actual *.js file are. To fix this I replaced dir option with this.opts.dir that made the report file go to the right path defined in the karma.config.js. This also wrote the index.html to right place instead of overwriting our application index.html. My change is shown here in the fork:
https://github.com/jannhama/istanbul
starting on line 474.
If you look at line 536, in istanbul/html.js you'll see that dir is correctly set by istanbul.
I don't know the tool that you are using, but maybe your problem is in there, and not in istanbul. In any case your change is not correct as writeFiles is supposed to receive the dir parameter from the caller, while your change actually ignores it.
We are running Karma to run the test cases. Karma config uses webpack config for directory structure but although I changed it manually it didn't affect anything. Seems that path is set to correct one there as you pointed out, however in the writeFiles for the coverage report path gets confused and it writes report files beside actual files and the report index.html in the end writes over our own.
I've got same issue yesterday. I used karma + webpack + remap-istanbul and I found that it ended up with node.name starting from //. In TreeSummarizer first slash is stripped, but second remains and it results with wrong path.
I prepared a fix for this.
That is great news! Thanks
This has been open for while now and @devfive has proposed a fix. Does it make sense? Can it be merged?
Most helpful comment
I've got same issue yesterday. I used karma + webpack + remap-istanbul and I found that it ended up with
node.namestarting from//. InTreeSummarizerfirst slash is stripped, but second remains and it results with wrong path.I prepared a fix for this.