Problem Statement
Show a simple unit test that checks a button click increments a counter.
Explanation
Mount the component, find the button, trigger a click, and assert the updated DOM or exposed state. Await Vue’s next tick or use flushPromises when async.
Code Solution
SolutionRead Only
// Vitest + VTU example
import { mount } from '@vue/test-utils'
import { describe, it, expect } from 'vitest'
import Counter from './Counter.vue'
describe('Counter', () => {
it('increments', async () => {
const w = mount(Counter)
await w.get('button').trigger('click')
expect(w.text()).toContain('1')
})
})