vue-test-chai

Custom chai assertions and language chains for vue-test-utils
2,654 1
Install
npm install vue-test-chai
Latest Version:1.0.0-3
Vue:2
License:MIT
Last Updated:Jan 13, 2019
Links: GitHub  ·  npm
Maintainer: jdoubleu

Chai plugin for Vue Test utils NPM version Build Status

This plugin adds assertions and language chains to chai for the Vue Test Utils.

Please note: This package is in early development. Please create an issue, if you experience any bugs or if you are missing a feature.

Why?

These custom assertions make your tests more readable and they provide better error messages in case of an error.

Example:

const wrapper = mount(MyComponent)

// instead of
expect(wrapper.attributes().id).to.equal('foo')
expect(wrapper.isEmpty()).to.be.false
// in case of an error it would throw:
// 1. AssertionError: expected 'bar' to equal 'foo'
// 2. AssertionError: expected true to be false

// write
expect(wrapper).to.have.attributes('id').which.equals('foo')
expect(wrapper).not.to.be.empty
// in case of an error it would throw:
// 1. AssertionError: Wrapper attributes: expected { Object (class) } to have property 'id'
// 2. AssertionError: expected { Object () } not to be empty, but it was

Installation

First install this package:

npm install --save-dev vue-test-chai

Then edit or create the setup script of your test runner (e.g. setup.js):

const chai = require('chai')
const vueTestChai = require('vue-test-chai')

chai.use(vueTestChai)

You can include any file in mocha using the --require flag.

Documentation

Related Packages

vue-test-utils-compat

Compat layer for @vue/test-utils@2.x

1,187,030
@vue/cli-plugin-unit-mocha

mocha unit testing plugin for vue-cli

1,130,090 29,510
@fromage/cli-plugin-unit-mocha

mocha unit testing plugin for vue-cli

1,462 29,511
@aisino/cli-plugin-unit-mocha

mocha unit testing plugin for vue-cli

948 29,511

Version History

Pre-releases (4)
Version Released Vue License
1.0.0-3 ^2.5.21 MIT
0.1.0-2 ^2.5.21 MIT
0.1.0-1 ^2.5.21 MIT
0.1.0-0 ^2.5.21 MIT