Complete the code to simulate a click event on the button.
<template> <button @click="increment">Click me</button> <p>Count: {{ count }}</p> </template> <script setup> import { ref } from 'vue' const count = ref(0) function increment() { count.value++ } // Test import { mount } from '@vue/test-utils' const wrapper = mount({ template: '<button @click="increment">Click me</button>', methods: { increment() {} } }) await wrapper.find('button').trigger([1]) </script>
Complete the code to check if the emitted event 'update' was triggered.
const wrapper = mount(MyComponent) await wrapper.find('input').setValue('new value') expect(wrapper.emitted()).toHaveProperty([1])
Fix the error in the test code to wait for the DOM update after clicking.
import { nextTick } from 'vue' await wrapper.find('button').trigger('click') [1] expect(wrapper.text()).toContain('Clicked')
Fill both blanks to test input value change and emitted event.
const input = wrapper.find('input') await input.setValue([1]) expect(wrapper.emitted()[[2]][0]).toEqual(['hello'])
Fill all three blanks to test a checkbox toggle and emitted event value.
const checkbox = wrapper.find('input[type="checkbox"]') await checkbox.setChecked([1]) expect(wrapper.emitted()[[2]][0]).toEqual([[3]])
