Complete the code to mount a Vue component fully using Vue Test Utils.
import { [1] } from '@vue/test-utils'; import MyComponent from './MyComponent.vue'; const wrapper = [1](MyComponent);
Use mount to fully mount the component including its child components.
Complete the code to mount a Vue component shallowly, stubbing child components.
import { [1] } from '@vue/test-utils'; import MyComponent from './MyComponent.vue'; const wrapper = [1](MyComponent);
shallowMount mounts the component but replaces child components with stubs.
Fix the error in the test code by choosing the correct mounting method to stub child components.
import { [1] } from '@vue/test-utils'; import ParentComponent from './ParentComponent.vue'; const wrapper = [1](ParentComponent); expect(wrapper.findComponent({ name: 'ChildComponent' }).text()).toBe('');
Use shallowMount to stub child components so they don't render fully.
Fill both blanks to mount a component shallowly and check if a child component is stubbed.
import { [1] } from '@vue/test-utils'; import Parent from './Parent.vue'; const wrapper = [1](Parent); const childStub = wrapper.findComponent({ name: '[2]' }); expect(childStub.exists()).toBe(true);
Use shallowMount to stub child components, and check for the stub by the child's name.
Fill all three blanks to mount a component fully, pass props, and check the rendered text.
import { [1] } from '@vue/test-utils'; import Greeting from './Greeting.vue'; const wrapper = [1](Greeting, { props: { message: '[2]' } }); expect(wrapper.text()).toContain('[3]');
Use mount to fully render the component with props, then check the text includes the message.