Full-Stack Web Development with Vue.js and Node

(singke) #1
Testing an MEVN Application Chapter 9

},
...

Now, let's run the test with the following command:


$ npm run unit

The test should pass with the following output:


Let's move on to add specs for the component called AddMovie.vue. Create a file called


AddMovie.spec.js inside test/unit/specs and add the following contents:


import Vue from 'vue';
import AddMovie from '@/components/AddMovie';

describe('AddMovie', () => {
let cmp, vm;

beforeEach(() => {
cmp = Vue.extend(AddMovie);
vm = new cmp({
data: {
years: ['2018', '2017', '2016', '2015']
}
}).$mount()
})

it('equals years to ["2018", "2017", "2016", "2015"]', () => {
console.log(vm.years);
Free download pdf