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

Failed to mount component: template or render function not defined

Open akxcv opened this issue 8 years ago • 1 comments
trafficstars

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request

Current behavior

When I try to use my single-file component, I get the following warning:

console.error node_modules/vue/dist/vue.js:482
  [Vue warn]: Failed to mount component: template or render function not defined.
      found in
      ---> <Vue$3>

Expected behavior

The component should work correctly.

Minimal reproduction of the problem with instructions Create a single-file component:

<template>
  <div>
    <span>{{ message }}</span>
    <button @click="reset"></button>
  </div>
</template>

<script>
  export default {
    name: 'what',
    props: ['message', 'reset'],
  }
</script>

Import it inside a test and try to use it in a Vue app

Please tell us about your environment:

I'm using Jest 21.2.1, vue 2.4.4 (vue/dist/vue.js with the compiler), node 6.10.0 (also tried 8.6.0).

  • jest-vue-preprocessor: 1.2.0
  • Node version: macOS with node 6.10.0 / 8.6.0

  • Platform: macOS

akxcv avatar Sep 29 '17 08:09 akxcv

The problem turned out to be the vue/dist/vue.js import. jest-vue-preprocessor only works if using a runtime-only build of Vue.

Is this normal?

akxcv avatar Sep 29 '17 18:09 akxcv