eddyerburgh / jest-serializer-vue

Jest Serializer for Vue components
MIT License
62 stars 22 forks source link

Support `v-slot` token #18

Closed iwata closed 3 years ago

iwata commented 5 years ago

Vue 2.6.0+ recommends v-slot instead of slot attribute. https://vuejs.org/v2/guide/components-slots.html#Named-Slots-with-the-slot-Attribute But jest-serializer-vue don't support it and using it causes an error. The actual error messages I encountered are listed below:

I'm using these versions:

 FAIL  test/index.spec.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    SyntaxError: Unexpected token (1:839)
    1 : function render () {with(this){return _c('main',{staticClass:"column main"},[_c('organized-breadcrumbs',{attrs:{"org-path":orgPath,"org-title":orgTitle}},[_c('li',[_c('a',[_v("Business")])]),_c('li',[_c('nuxt-link',{attrs:{"to":termsPath}},[_v("利用規約文書")])],1),_c('li',{staticClass:"is-active"},[_c('a',{attrs:{"aria-content":"page"}},[_v(_s(title))])])]),_c('business-tabs',{attrs:{"org":org,"active":"terms"}},[_c('template',{slot:"terms"},[_c('term-document',{attrs:{"title":title,"original-body":original.body,"body":body,"is-processing":isProcessing,"enable-button":hasDiff,"services":services,"is-editting":true,"can-save":canSave,"can-remove":canRemove},on:{"update:title":function($event){title=$event},"update:body":function($event){body=$event},"save":save,"remove":removeConfirm},scopedSlots:_u([{key:"service-list",fn:function(v-slot:service-list){return _l((services),function(service){return _c('b-tag',{key:service.id,attrs:{"type":"is-info"}},[_v(_s(service.groupRef.name)+" / "+_s(service.name))])})}}])})],1)],2)],1)}}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ^

      at Parser.pp$4.raise (node_modules/vue-template-es2015-compiler/buble.js:2757:13)
      at Parser.pp.unexpected (node_modules/vue-template-es2015-compiler/buble.js:647:8)
      at Parser.pp.expect (node_modules/vue-template-es2015-compiler/buble.js:641:26)
      at Parser.pp$2.parseBindingList (node_modules/vue-template-es2015-compiler/buble.js:1694:19)
      at Parser.pp$1.parseFunctionParams (node_modules/vue-template-es2015-compiler/buble.js:1231:22)
      at Parser.pp$1.parseFunction (node_modules/vue-template-es2015-compiler/buble.js:1218:8)
      at Parser.pp$3.parseExprAtom (node_modules/vue-template-es2015-compiler/buble.js:2184:17)
      at Parser.<anonymous> (node_modules/vue-template-es2015-compiler/buble.js:6003:24)
      at Parser.parseExprAtom (node_modules/vue-template-es2015-compiler/buble.js:6129:31)
      at Parser.pp$3.parseExprSubscripts (node_modules/vue-template-es2015-compiler/buble.js:2047:19)
iwata commented 5 years ago

Do you have any responses?

TheJaredWilcurt commented 4 years ago

@iwata Can you try with my fork?

If the issue still occurs. You can create an issue on that repo with a code sample to reproduce it, and I'll take a look.