Description
Refer #1372 (comment)
This PR may break the istanbul coverage html reporter.
when building coverage data in browser:
such as babel-plugin-istanbul will store absolute path path/to/file.vue.js
as file path key, but the real path is path/to/file.vue
.
https://github.com/istanbuljs/babel-plugin-istanbul/blob/master/src/index.js#L8-L14
function getRealpath (n) {
try {
return realpathSync(n) || n // <= path/module.vue not found
} catch (e) {
return n // <= goes here return path/module.vue.js
}
}
when consuming coverage to build html reporter:
such as istanbul etc. the resourcePath is used by the test coverage reporter to read source file from local disk
Error detail
{ Error: ENOENT: no such file or directory, open
'/builds/path/to/src/components/some-module.vue.js'
You can see the generated file path in browser's console: install babel-plugin-istanbul
and put this in .babelrc
"plugins": [
"istanbul"
]
then check window.__coverage__
variable
Maybe we can add a new option for this feature, and not enable by default
Another typescript and remap-istanbul related issue:
It's also breaking https://github.com/SitePen/remap-istanbul 's source remap since remap uses extname for filename replacement
see https://github.com/SitePen/remap-istanbul/blob/master/src/CoverageTransformer.js#L144
I found a solution for resolving this issue: SitePen/remap-istanbul#143
use mapFileName config, this will create clean test coverage report (without displaying querystring and transformed extname after source file name) again:
remap(__coverage__, {
mapFileName: filename => {
const originName = filename.replace(/\.vue\.[jt]s(\?.+)?$/, '.vue');
return originName;
}
});