forked from vuejs/vue-cli
/
example.spec.ts
45 lines (39 loc) · 1.06 KB
/
example.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<%_ if (hasTS) { _%>
<%_ if (!rootOptions.bare || !hasRouter) { _%>
import { shallowMount } from '@vue/test-utils'
<%_ } else { _%>
import { mount, createLocalVue } from '@vue/test-utils'
<%_ } _%>
<%_ if (!rootOptions.bare) { _%>
import HelloWorld from '@/components/HelloWorld.vue'
describe('HelloWorld.vue', () => {
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(HelloWorld, {
propsData: { msg }
})
expect(wrapper.text()).toMatch(msg)
})
})
<%_ } else { _%>
import App from '@/App.vue'
<%_ if (!hasRouter) { _%>
test('App should work', () => {
const wrapper = shallowMount(App)
expect(wrapper.text()).toMatch(`Welcome to Your Vue.js + TypeScript App`)
})
<%_ } else {_%>
import VueRouter from 'vue-router'
import router from '@/router'
const localVue = createLocalVue()
localVue.use(VueRouter)
test('App should render default route', () => {
const wrapper = mount(App, {
localVue,
router
})
expect(wrapper.text()).toMatch(`Welcome to Your Vue.js App`)
})
<%_ } _%>
<%_ } _%>
<%_ } _%>