vue-jest icon indicating copy to clipboard operation
vue-jest copied to clipboard

Improve error handling

Open sktzofrenic opened this issue 6 years ago • 3 comments

Here is the error I'm getting:

    [vue-jest] Error: Vue template compilation failed

      1 | import { shallowMount } from '@vue/test-utils'
    > 2 | import Problem from './../../src/components/Problem.vue'
        | ^
      3 |
      4 | describe('Problem.vue', () => {
      5 |     it('initializes and sets up correctly', () => {

      at error (node_modules/vue-jest/lib/throw-error.js:2:9)
      at Object.<anonymous> (tests/unit/problem.spec.js:2:1)

Please see this git repo for reproduction:

https://github.com/sktzofrenic/jest-problem

run

$ cd hello-world $ npm run test:unit

This is basically a vanilla vue-cli project with one added component that is generating this issue.

I cannot figure out what won't compile about this template.

When I build for production it compiles just fine and this component works on the live site. I just can't test it for some reason.

I would appreciate any assistance. Thank you!

sktzofrenic avatar Feb 06 '19 14:02 sktzofrenic

This was my mistake as it was almost impossible for me to see, but there were two class attributes on one dom element and the compiler was correctly telling me this was wrong. Two things that are still confusing:

  1. Why did vue-jest not tell me where the error was? That is a possible improvement and would have saved a lot of time. Instead it just told me the import statement was where the error was.
  2. Why does the production vue-template-compiler compile this without warnings or errors?

Thanks

sktzofrenic avatar Feb 07 '19 12:02 sktzofrenic

https://github.com/vuejs/vue-jest/issues/170#issuecomment-479467801 was the solution in my case

OrkhanAlikhanov avatar Jun 06 '20 12:06 OrkhanAlikhanov

in my case the problem was an inline emit call

rrd108 avatar Oct 19 '21 10:10 rrd108