1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
import HelloWorld from '@/components/HelloWorld.vue' import Vue from 'vue' import { expect } from 'chai' import { mount } from '@vue/test-utils'
describe('HelloWorld.vue', () => { it('原生自己测试vue 传递属性能否正常显示', () => { const Constructor = Vue.extend(HelloWorld) const vm = new Constructor({ propsData: { msg: 'hello world' }, }).$mount() expect(vm.$el.querySelector('h1')?.innerHTML).to.be.eq('hello world') }) }) describe('HelloWorld.vue', () => { it('通过 @vue/test-utils 测试 传递属性能否正常显示', () => { const wrapper = mount(HelloWorld, { propsData: { msg: 'hello' }, }) expect(wrapper.get('h1').text()).to.be.eq('hello world') }) })
|