Complete the code to create a simple test that checks if a Vue component renders correctly.
import { mount } from '@vue/test-utils' import HelloWorld from './HelloWorld.vue' test('renders message', () => { const wrapper = mount(HelloWorld) expect(wrapper.text()).toContain([1]) })
We use a string with quotes to check if the rendered text contains 'Hello World'.
Complete the code to simulate a button click in a Vue test.
const wrapper = mount(ButtonComponent) await wrapper.find('button').[1] expect(wrapper.emitted()).toHaveProperty('click')
We use trigger to simulate DOM events like clicks in Vue tests.
Fix the error in the test by completing the code to wait for Vue's DOM updates.
import { nextTick } from 'vue' const wrapper = mount(Component) wrapper.setData({ count: 1 }) await [1]() expect(wrapper.text()).toContain('1')
Vue's nextTick waits for DOM updates after data changes.
Fill both blanks to create a computed property and use it in the template.
<template>
<p>{{ [1] }}</p>
</template>
<script setup>
import { computed, ref } from 'vue'
const count = ref(0)
const [2] = computed(() => count.value * 2)
</script>The computed property is named doubleCount and used in the template with the same name.
Fill all three blanks to create a reactive state, update it, and check the rendered output.
<template> <button @click="[1]">Increment</button> <p>{{ count }}</p> </template> <script setup> import { ref } from 'vue' const count = ref(0) function [2]() { count.value [3] 1 } </script>
The button calls the increment function which increases count.value by 1 using +=.