vuejs-templates / webpack

A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.
MIT License
9.7k stars 4.39k forks source link

Jests tests fail #1260

Open ccamarat opened 6 years ago

ccamarat commented 6 years ago

Steps to reproduce:

  1. vue init webpack jest-test
  2. Runtime + Compiler
  3. Install Vue Router
  4. Use eSLint - Y
  5. ...config standard
  6. Set up Unit Tests - Y
  7. ...Jest
  8. Setup Nightwatch - Y
  9. Use NPM
  10. cd jest-test
  11. npm run unit

Expected Result: Tests pass with coverage report

Actual Result: Tests fail with error:

 FAIL  test\unit\specs\HelloWorld.spec.js
  ● Test suite failed to run

    No file coverage available for: d:\tmp\test-jest2\src\components\HelloWorld.vue

      at CoverageMap.fileCoverageFor (node_modules/istanbul-lib-coverage/lib/coverage-map.js:96:15)
          at Array.forEach (<anonymous>)

Environment: Windows 10 / Node 8.9.3 / NPM 5.5.1

Other Info This broke over the weekend. It's not clear to me what changed so it seems likely to me this is really problem with one of this project's dependencies, but I could use a hand tracking down which one.

LinusBorg commented 6 years ago

Seems to be an upstream issue? https://github.com/vuejs/vue-jest/issues/48

ccamarat commented 6 years ago

Yea, I'm sure it is now. I was excited to start using Jest; it is much easier to setup than Jasmine or Mocha, so I was disappointed when it just stopped working.

Does this look like a Windows-only thing to you, or is it happening on other platforms?

ccamarat commented 6 years ago

I was able to throw a couple hours at this one today. I've got a successful (if limited) workaround and was able to determine that the issue was introduced with Jest v22.0.0. I also have some info that may help someone track this down or resolve; I posted them over at the Vue-Jest repo since I'm thinking that's where the fix will be.

Work Around Place the Jest configuration directly inside package.json following the vue test utils jest-example. If you need any type of dynamic config obviously this won't be very helpful, but maybe it'll help someone.