Custom chai assertions and language chains for vue-test-utils
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Joshua Westerheide 654171c67d
Fix find and findAll assertions
2 years ago
docs Fixe @type in JSDoc of seme property assertions 2 years ago
lib Fix find and findAll to respect negate flag 2 years ago
scripts Move index file into lib folder 2 years ago
test Fix find and findAll to respect negate flag 2 years ago
.eslintrc.json Setup eslint 2 years ago
.gitignore Initialize npm package 2 years ago
.travis.yml Add travis-ci config 2 years ago
LICENSE Add MIT license file 2 years ago
README.md Add API docs 2 years ago
helpers.jsdoc.js Update api docs rendering 2 years ago
package-lock.json Fix find and findAll assertions 2 years ago
package.json Fix find and findAll assertions 2 years ago

README.md

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