forked from vitest-dev/vitest
/
vue.test.ts
45 lines (32 loc) · 1 KB
/
vue.test.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
/**
* @vitest-environment happy-dom
*/
import { expect, test } from 'vitest'
import { mount } from '@vue/test-utils'
import Hello from '../src/Hello.vue'
import Defined from '../src/Defined.vue'
import { CounterVue } from '../src/Counter'
test('vue 3 coverage', async () => {
expect(Hello).toBeTruthy()
const wrapper = mount(Hello, {
props: {
count: 4,
},
})
expect(wrapper.text()).toContain('4 x 2 = 8')
expect(wrapper.html()).toMatchSnapshot()
await wrapper.get('button').trigger('click')
expect(wrapper.text()).toContain('4 x 3 = 12')
await wrapper.get('button').trigger('click')
expect(wrapper.text()).toContain('4 x 4 = 16')
})
test('define package in vm', () => {
expect(Defined).toBeTruthy()
const wrapper = mount(Defined)
expect(wrapper.text()).toContain(MY_CONSTANT)
})
test('vue non-SFC, uses query parameters in file imports', async () => {
const wrapper = mount(CounterVue)
await wrapper.find('button').trigger('click')
expect(wrapper.text()).contain(1)
})