diff --git a/README.md b/README.md index 3997f15..764ee00 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,13 @@ - 🔥 Use the [new ` + + diff --git a/test/__snapshots__/component.test.ts.snap b/test/__snapshots__/component.test.ts.snap new file mode 100644 index 0000000..aa529f1 --- /dev/null +++ b/test/__snapshots__/component.test.ts.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Counter.vue > should render 1`] = `"
10
"`; diff --git a/test/basic.test.ts b/test/basic.test.ts new file mode 100644 index 0000000..542fa32 --- /dev/null +++ b/test/basic.test.ts @@ -0,0 +1,7 @@ +import { describe, it, expect } from 'vitest' + +describe('Hi', () => { + it('should works', () => { + expect(1 + 1).toEqual(2) + }) +}) diff --git a/test/component.test.ts b/test/component.test.ts new file mode 100644 index 0000000..ba014df --- /dev/null +++ b/test/component.test.ts @@ -0,0 +1,22 @@ +import { mount } from '@vue/test-utils' +import { describe, it, expect } from 'vitest' +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') + }) +}) diff --git a/vite.config.ts b/vite.config.ts index eeca3df..e93384a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -25,6 +25,7 @@ export default defineConfig({ 'vue', 'vue-router', '@vueuse/core', + 'vitest', ], dts: true, }), @@ -60,4 +61,8 @@ export default defineConfig({ 'vue-demi', ], }, + + test: { + dom: 'jsdom', + }, })