import { expect } from 'chai'
import { mount } from '@vue/test-utils'
import Vue from 'vue'
import HelloWorld from '../../components/HelloWorld.vue'
import Count from '../../components/Count.vue'
describe('比较测试', () => {
it('大小关系', () => {
expect(5).to.greaterThan(3);
})
it('相等关系', () => {
expect([1, 2, 3]).to.be.lengthOf(3);
})
it('包含关系', () => {
expect('aeipyuan').to.be.contain('aeip');
})
})
describe('Hello World.vue', () => {
it('正常显示msg', () => {
let wrapper = mount(HelloWorld, {
propsData: { msg: 'hello' }
});
expect(wrapper.find('h1').text()).to.be.contain('hello')
})
})
describe('Count.vue', () => {
it('测试点击计数', () => {
let wrapper = mount(Count);
expect(wrapper.find('#count').text()).to.be.equal('10');
wrapper.find('#btn').trigger('click');
expect(wrapper.find('#count').text()).to.be.equal('11');
})
})
{
"name": "util2",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"core-js": "^3.6.4",
"vue": "^2.6.11",
"vuex": "^3.1.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.3.0",
"@vue/cli-plugin-unit-mocha": "~4.3.0",
"@vue/cli-plugin-vuex": "~4.3.0",
"@vue/cli-service": "~4.3.0",
"@vue/test-utils": "1.0.0-beta.31",
"chai": "^4.1.2",
"vue-template-compiler": "^2.6.11"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}