feat: integrate vitest

This commit is contained in:
Anthony Fu committed 2021-12-26 13:16:12 +08:00
1 parent 1f405bbc0d
commit c0201aed28
12 files changed
+183 -14

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { mount } from '@vue/test-utils'
import Counter from '../src/components/Counter.vue'
describe('Counter.vue', () => {
it('should render', () => {
const wrapper = mount(Counter, { props: { initial: 10 } })
expect(wrapper.text()).toContain('10')
expect(wrapper.html()).toMatchSnapshot()
})
it('should be interactive', async() => {
const wrapper = mount(Counter, { props: { initial: 0 } })
expect(wrapper.text()).toContain('0')
expect(wrapper.find('.inc').exists()).toBe(true)
await wrapper.get('button').trigger('click')
expect(wrapper.text()).toContain('1')
})
})