Skip to content

Pug + Vue named template slot + Istanbul fails to build coverage with Jest #197

Open
@nothingismagick

Description

@nothingismagick

Version

1.0.0-beta.29

Reproduction link

quasarframework/quasar-testing#87

Steps to reproduce

With a very simple example of using a named slot Istanbul coverage within Jest fails:

<template lang="pug">
  q-layout(view="lHh Lpr lFf")
    q-input()
      template(v-slot:append)
        h2 asdf
</template>

Stacktrace

Running coverage on untested files...Failed to collect coverage from pug-test/src/layouts/MyLayout.vue
ERROR: Unexpected token (1:141)
STACK: SyntaxError: Unexpected token (1:141)
    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)

Fix 1

<template lang="pug">
  q-layout(view="lHh Lpr lFf")
    q-input()
      template(v-slot:append="")
        h2 asdf
</template>

Adding the ="" seems to be good enough for Istanbul not to complain, and quasar renders it as expected. I don't like this workaround, though its slightly better than this one:

Fix 2

<template lang="pug">
  q-layout(view="lHh Lpr lFf")
    q-input()
      <template v-slot:append>
        <h2>asdf</h2>
      </template>
</template>

What is expected?

No Stacktrace shown, no errors.

What is actually happening?

Stacktrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions