avoriaz
avoriaz
a Vue.js testing utility library
Deprecation
This library will be deprecated once vue-test-utils is released.
Installation
npm install --save-dev avoriaz
Documentation
Examples
- Example using karma and mocha
- Example using karma and jasmine
- Example using Jest
- Example using mocha-webpack
- Example using tape
- Example using ava
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'
})
For more examples, see the docs
Dependencies
Dependencies
babel-cli: ^6.18.0babel-core: ^6.21.0babel-eslint: ^7.2.3babel-loader: ^6.2.10babel-plugin-istanbul: ^3.1.2babel-plugin-transform-flow-strip-types: ^6.22.0babel-plugin-transform-runtime: ^6.15.0babel-preset-es2015: ^6.18.0babel-preset-stage-2: ^6.18.0chai: ^3.5.0cross-env: ^3.1.4css-loader: ^0.26.1eslint: ^4.5.0eslint-config-airbnb: ^15.1.0eslint-plugin-flowtype: ^2.35.0eslint-plugin-import: ^2.7.0eslint-plugin-jsx-a11y: ^5.1.1eslint-plugin-mocha: ^4.9.0eslint-plugin-vue: ^2.1.0flow-bin: ^0.51.0gitbook-cli: ^2.3.0istanbul: ^0.4.5jsdom: ^9.9.1json-loader: ^0.5.4karma: ^1.3.0karma-chrome-launcher: ^2.0.0karma-coverage: ^1.1.1karma-mocha: ^1.3.0karma-phantomjs-launcher: ^1.0.2karma-sinon-chai: ^1.2.4karma-sourcemap-loader: ^0.3.7karma-spec-reporter: 0.0.26karma-webpack: ^1.8.1mocha: ^3.2.0mocha-webpack: ^0.7.0rimraf: ^2.5.4rollup: ^0.45.2rollup-plugin-buble: ^0.15.0rollup-plugin-commonjs: ^8.2.0rollup-plugin-flow-no-whitespace: ^1.0.0rollup-plugin-node-resolve: ^3.0.0sinon: ^2.2.0sinon-chai: ^2.8.0tslint: ^5.5.0typescript: ^2.4.2vue: ^2.4.2vue-loader: ^12.1.1vue-style-loader: ^1.0.0vue-template-compiler: ^2.4.2vuex: ^2.3.1webpack: ^1.14.0