avoriaz 介绍
一个 vue.js测试实用程序库?
安装
npm install --save-dev avoriaz
Assert wrapper contains a childimport { mount } from 'avoriaz'
import Foo from './Foo.vue'
const wrapper = mount(Foo)
expect(wrapper.contains('.bar')).to.equal(true)
Shallow render components import { shallow } from 'avoriaz'import Foo from './Foo.vue'import Bar from './Bar.vue'const wrapper = shallow(Foo)expect(wrapper.contains(Bar)).to.equal(true) Assert style is renderedconst button = wrapper.find('div > button .button-child')[0]
expect(button.ha sst yle('color','red')).to.equal(true)
Assert method is called when DOM event is triggeredconst clickHandler = sinon.stub()
const wrapper = mount(Foo,{
propsData: { clickHandler }
})
wrapper.find('div .bar')[0].trigger('click')
expect(clickHandler.called).to.equal(true)
Assert wrapper contains textconst title = wrapper.find('h1.title')[0]
expect(title.text()).to.equal('some text')
Inject globalsconst $route = { path: 'http://www.example-path.com' }
const wrapper = mount(Foo,{
globals: {
$route
}
})
expect(wrapper.vm.$route.path).to.equal($route.path)
Inject slotsconst wrapper = mount(Foo,{
slots: {
default: Foo
}
})
Set datawrapper.setData({
someData: 'some data'
})
expect(wrapper.vm .so meData).to.equal('some data')
Update propswrapper.setProps({
someProp: 'some prop',
anotherProp: 'another prop'
})
?
网站地址 : https://eddyerburgh.gitbooks.io/avoriaz/content/
GitHub: https://github.com/eddyerburgh/avoriaz
网站描述: 一个 Vue.js测试工具类库
avoriaz官方网站
官方网站: https://eddyerburgh.gitbooks.io/avoriaz/content/
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。