import { mount } from '@vue/test-utils'
import MyComponent from '../MyComponent.vue'
describe('MyComponent', () => {
test('renders correctly', () => {
const wrapper = mount(MyComponent, {
propsData: {
message: 'Hello World'
}
})
expect(wrapper.text()).toMatch('Hello World')
})
})
此测试用例将渲染一个包含消息“Hello World”的MyComponent组件,并断言该消息是否在DOM中显示。
请注意,这只是测试的一部分,您的测试用例应该尽可能完整和准确地覆盖您的组件。
上一篇:不能通过事件字段选择和筛选消息。