avoriaz 介绍
一个vue.js测试实用程序库
安装
npm install --save-dev avoriaz
Assert wrapper contains a child
import { 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 rendered
const button = wrapper.find('div > button .button-child')[0]
expect(button.hasStyle('color','red')).to.equal(true)
Assert method is called when DOM event is triggered
const 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 text
const title = wrapper.find('h1.title')[0]
expect(title.text()).to.equal('some text')
Inject globals
const $route = { path: 'http://www.example-path.com' }
const wrapper = mount(Foo,{
globals: {
$route
}
})
expect(wrapper.vm.$route.path).to.equal($route.path)
Inject slots
const wrapper = mount(Foo,{
slots: {
default: Foo
}
})
Set data
wrapper.setData({
someData: 'some data'
})
expect(wrapper.vm.someData).to.equal('some data')
Update props
wrapper.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/
小编说
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。