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

Extname added by loader causes coverage reporter error: 'Error: ENOENT: no such file or directory' #1388

Closed
zhangyuheng opened this issue Aug 23, 2018 · 1 comment

Comments

@zhangyuheng
Copy link

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;
  }
});
@vue-bot
Copy link

vue-bot commented Aug 23, 2018

Hello, your issue has been closed because it does not conform to our issue requirements. In order to ensure every issue provides the necessary information for us to investigate, we require the use of the Issue Helper when creating new issues. Thank you!

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