vuejs / vue-test-utils-mocha-webpack-example

Example project using mocha-webpack and vue-test-utils
104 stars 48 forks source link

Missing `List.vue` file in coverage report #3

Open vitoravelino opened 6 years ago

vitoravelino commented 6 years ago

Hello there!

I pulled the code, ran npm install and List.vue does not appear in the coverage report files. Is that expected?

 WEBPACK  Compiled successfully in 476ms

 MOCHA  Testing...

  List.vue
    ✓ renders li for each item in props.items

  Message
    ✓ renders props.msg when passed
    ✓ renders default message if not passed a prop

  MessageToggle.vue
    ✓ toggles msg passed to Message when button is clicked

  4 passing (26ms)

 MOCHA  Tests completed successfully

----------------------------|----------|----------|----------|----------|----------------|
File                        |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
----------------------------|----------|----------|----------|----------|----------------|
All files                   |      100 |      100 |      100 |      100 |                |
 Message.js                 |      100 |      100 |      100 |      100 |                |
 MessageToggle.vue?d4b1857c |      100 |      100 |      100 |      100 |                |
----------------------------|----------|----------|----------|----------|----------------|
vitoravelino commented 6 years ago

Also, I passed --reporter=html to check the output in the browser and when I opened the vue file I got:

Unable to lookup source: /home/vitoravelino/Workspace/others/vue-test-utils-mocha-webpack-example/src/components/MessageToggle.vue?d4b1857c(ENOENT: no such file or directory, open '/home/vitoravelino/Workspace/others/vue-test-utils-mocha-webpack-example/src/components/MessageToggle.vue?d4b1857c')

dbschwartz commented 6 years ago

I had the same problem! I found the issue answered here in the nyc issue page. Looks like if you change devtool: 'inline-cheap-module-source-map' to devtool:'eval' in webpack.config.js it works! Although, this is not what mocha-webpack recommends in their documentation it seems to be a good workaround. The inline-cheap-module-source-map seems to be incompatible with .vue files.

vitoravelino commented 6 years ago

Thanks for the tip, @dbschwartz. I'll check that out later!

dbschwartz commented 6 years ago

No prob @vitoravelino! It's actually devtool not dev. My bad. I fixed the original post