0

My folder structure is this:

./package.json

src/Notification.js

test/notification.js

File Notification.js

export default {
  template: '<div>{{message}}</div>',
  data() {
    return {
      message: 'Hello world'
    };
  }
};

File notification.js

import Vue from 'vue';
import test from 'ava';
import Notification from '../src/Notification';
test('that it renders a notification', t => {
  new Vue(Notification).$mount();
});

Error when i run: node_modules/.bin/ava

[Vue warn]: You are using the runtime-only build of Vue where the 
template compiler is not available. Either pre-compile the templates
into render functions, or use the compiler-incluided build. (found in
<Root>)
1failed
that it renders a notification
test finished without running any assertions

If someone can say me what's wrong and explain the code, i will really appreciate it.

Lluís Puig Ferrer
  • 1,128
  • 7
  • 19
  • 49

2 Answers2

1

Your test did not use any assertions. You probably want to assert something on the new Vue(Notification).$mount() return value. If you're just making sure it doesn't throw an exception you could do t.notThrows(() => new Vue(Notification).$mount()).

Mark Wubben
  • 3,329
  • 1
  • 19
  • 16
0

Vue ships with several versions, some with the template compiler and some without. The way you are importing Vue now, the template compiler is not included, so Vue cannot compile

template: '<div>{{message}}</div>',

Try instead importing a version of Vue with the compiler.

import Vue from "vue/dist/vue"
Bert
  • 80,741
  • 17
  • 199
  • 164