All Projects → callumacrae → Vue Test

callumacrae / Vue Test

🏁 DEPRECATED: Component testing for Vue.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Test

Memote
memote – the genome-scale metabolic model test suite
Stars: ✭ 73 (-20.65%)
Mutual labels:  unit-testing
Android Mvp Architecture
MVP + Kotlin + Retrofit2 + Dagger2 + Coroutines + Anko + Kotlin-Android-Extensions + RX-java + Mockk + Espresso + Junit5
Stars: ✭ 82 (-10.87%)
Mutual labels:  unit-testing
Netdumbster
netDumbster is a .Net Fake SMTP Server clone of the popular Dumbster
Stars: ✭ 88 (-4.35%)
Mutual labels:  unit-testing
Tcunit
An unit testing framework for Beckhoff's TwinCAT 3
Stars: ✭ 74 (-19.57%)
Mutual labels:  unit-testing
Sample Code Movies
This repository contains sample code. Its purpose being, to quickly demonstrate Android and software development in general, clean code, best practices, testing and all those other must know goodies.
Stars: ✭ 81 (-11.96%)
Mutual labels:  unit-testing
Autoparams
Arbitrary test data generator for parameterized tests in Java inspired by AutoFixture.
Stars: ✭ 77 (-16.3%)
Mutual labels:  unit-testing
Publish Unit Test Result Action
GitHub Action to publish unit test results on GitHub
Stars: ✭ 71 (-22.83%)
Mutual labels:  unit-testing
Phpunit Json Assert
PHPUnit assertions for JSON documents
Stars: ✭ 90 (-2.17%)
Mutual labels:  unit-testing
Sequelize Test Helpers
A collection of utilities to help with unit-testing Sequelize models
Stars: ✭ 83 (-9.78%)
Mutual labels:  unit-testing
Rubberduck
Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
Stars: ✭ 1,287 (+1298.91%)
Mutual labels:  unit-testing
Go Script Bash
Framework for writing modular, discoverable, testable Bash scripts
Stars: ✭ 77 (-16.3%)
Mutual labels:  unit-testing
Semaphore Ng2 Webpack
Stars: ✭ 81 (-11.96%)
Mutual labels:  unit-testing
Vest
Vest ✅ Declarative validations framework
Stars: ✭ 1,271 (+1281.52%)
Mutual labels:  unit-testing
Sinon
Test spies, stubs and mocks for JavaScript.
Stars: ✭ 8,828 (+9495.65%)
Mutual labels:  unit-testing
Bitsofbytes
Code and projects from my blog posts.
Stars: ✭ 89 (-3.26%)
Mutual labels:  unit-testing
Aunit
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test. Used with AUniter or EpoxyDuino for continuous builds.
Stars: ✭ 73 (-20.65%)
Mutual labels:  unit-testing
Jasmine Marbles
Marble testing helpers for RxJS and Jasmine
Stars: ✭ 85 (-7.61%)
Mutual labels:  unit-testing
React Redux Starter Kit
Modular starter kit for React+Redux+React Router projects.
Stars: ✭ 92 (+0%)
Mutual labels:  unit-testing
Saul
Experimental annotation-based javascript unit tests 🚀
Stars: ✭ 90 (-2.17%)
Mutual labels:  unit-testing
Testing Workshop
A workshop for learning how to test JavaScript applications
Stars: ✭ 1,276 (+1286.96%)
Mutual labels:  unit-testing

vue-test Build Status

Component testing utilities for Vue.js (work with both Vue 1 and 2)

Installation

$ npm install --save-dev vue-test

Usage

The library is divided into two parts: the mount() function and the chai assertion library plugin. The mount() function is used for mounting components in your tests without having to directly interact with the DOM, and the chai plugin can be used to write readable tests with understandable output for mounted Vue components.

NOTE: vue-test requires the full version of Vue (which includes the compiler). Make sure your build configuration for testing aliases vue properly. For example (webpack 2):

{
  resolve: {
    alias: {
      'vue$': 'vue/dist/vue.esm.js'
    }
  }
}

The mount() function

The mount() function takes two arguments, a Vue component, and some optional properties, and returns a wrapped mounted component with some useful utility functions.

import { mount } from 'vue-test';
import Title from './Title.vue';

const mountedTitle = mount(Title, {
  title: 'Hello world!'
});

mountedTitle.find('h1').text(); // Hello world!

Check out mount-api.md for a full list of the available functions.

Chai plugin

vue-test includes a chai plugin which you can use to test a component mounted with the mount() function.

Here's how you add it:

import { chaiPlugin } from 'vue-test';
chai.use(chaiPlugin);

Here's a very quick overview of what you can do:

  • expect(mountedComponent).to.be.ok
  • expect(mountedComponent).to.be.tag('p')
  • expect(mountedComponent).to.contain.tag('p')
  • expect(mountedComponent).to.match.selector('#id .class')
  • expect(mountedComponent).to.contain.selector('#id .class')
  • expect(mountedComponent).to.be.empty
  • expect(mountedComponent).to.have.className('alert')
  • expect(mountedComponent).to.have.value('input value')
  • expect(mountedComponent).to.have.text('some text')
  • expect(mountedComponent).to.contain.text('some text')
  • expect(mountedComponent).to.have.attribute('style')
  • expect(mountedComponent).to.have.attribute('style').that.equals('something')

It's all pretty descriptive and understandable, but for full explanations, see chai-plugin-api.md.

Contributing

If you feel something is missing or find a bug, feel free to send a PR or open an issue. If you haven't contributed to a project on GitHub before, feel free to ask me for help and I can help you out 😄

License

This project is released under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].