vue-jest
vue-jest copied to clipboard
Improve error handling
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!
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:
- 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.
- Why does the production vue-template-compiler compile this without warnings or errors?
Thanks
https://github.com/vuejs/vue-jest/issues/170#issuecomment-479467801 was the solution in my case
in my case the problem was an inline emit call