Vue-test-utils: vue 2.6+ named slot and pug will make jest broken

Created on 17 Apr 2019  ยท  3Comments  ยท  Source: vuejs/vue-test-utils

Version

1.0.0-beta.29

Reproduction link

https://github.com/yoyoys/vue-slot-pug-bug-jest-reproduction

Steps to reproduce

  1. create project by vue-cli 3.6.3, using jest, TypeScript, TSLint, Class Component
  2. npm i -D pug pug-plain-loader
  3. add a component which has named slot (SlotGuy.vue)
  4. run npm run test:unit

What is expected?

test run success

What is actually happening?

I've got a error below:

  โ— Test suite failed to run

    SyntaxError: Unexpected character '#' (1:150)

      at Parser.pp$4.raise (node_modules/vue-template-es2015-compiler/buble.js:2757:13)
      at Parser.pp$8.getTokenFromCode (node_modules/vue-template-es2015-compiler/buble.js:4906:8)
      at Parser.pp$8.readToken (node_modules/vue-template-es2015-compiler/buble.js:4628:15)
      at Parser.readToken (node_modules/vue-template-es2015-compiler/buble.js:6029:22)
      at Parser.pp$8.nextToken (node_modules/vue-template-es2015-compiler/buble.js:4619:15)
      at Parser.pp$8.next (node_modules/vue-template-es2015-compiler/buble.js:4576:8)
      at Parser.pp.eat (node_modules/vue-template-es2015-compiler/buble.js:577:10)
      at Parser.pp.expect (node_modules/vue-template-es2015-compiler/buble.js:641:8)
      at Parser.pp$1.parseFunctionParams (node_modules/vue-template-es2015-compiler/buble.js:1230:8)
      at Parser.pp$1.parseFunction (node_modules/vue-template-es2015-compiler/buble.js:1218:8)

Most helpful comment

workround here:
replace

template(#boom)

into this

template(#boom="")

All 3 comments

workround here:
replace

template(#boom)

into this

template(#boom="")

Thanks for this, this bug will need to be fixed in vue-jest, so I've moved your issue there: https://github.com/vuejs/vue-test-utils/issues/1210

Was this page helpful?
0 / 5 - 0 ratings