• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Extract custom test blocks from Vue components

vue-test-loader

Extract custom test blocks into .spec files

Usage

Install the loader:

npm install --save-dev vue-test-loader

Setup vue-loader to pass the test block to the loader:

module.exports = {
  // The rest of the config
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          loaders: {
            'test': 'vue-test-loader'
          },
        }
      }
    ]
  }
}

Write tests inside a custom block:

<template>
  <div />
</template>

<script>
export default {
  name: 'example-component'
}
</script>

<test>
import { shallow } from 'vue-test-utils'
import ExampleComponent from './ExampleComponent'

describe('ExampleComponent', () => {
    test('is div', () => {
      expect(shallow(ExampleComponent).is('div')).toBe(true)
    })
})
</test>

vue-test-loader will create a .spec.js file in a __tests__ directory inside the component directory.

This works best with Jest.

Options

Name Description Default
extension string of file extension '.spec.js'
{
  test: /\.vue$/,
  loader: 'vue-loader',
  options: {
    loaders: {
      'test': [{
          loader: path.resolve(__dirname,'../index.js'),
          options: {
              extension: '.test.js'
          }
      }]
    },
  }
}

Examples

You can see an example project using Jest here

More Repositories

1

avoriaz

πŸ”¬ a Vue.js testing utility library
JavaScript
761
star
2

vue-hackernews

A Vue hacker news application with tests
JavaScript
157
star
3

simple-redux

A bare-bones redux implementation for teaching purposes πŸŽ“
JavaScript
114
star
4

jest-transform-stub

Jest stub transform
JavaScript
113
star
5

vue-test-utils-jest-example

An example vue-test-utils project with jest
JavaScript
91
star
6

vue-unit-test-perf-comparison

Comparison of Vue SFC unit tests using different test runners
JavaScript
64
star
7

parcel-vuejs-template

Parcel template for Vue CLI
JavaScript
63
star
8

jest-serializer-vue

Jest Serializer for Vue components
JavaScript
62
star
9

notes

Notes on computer science https://notes.eddyerburgh.me/ πŸ“š
TeX
59
star
10

vue-test-utils-vuex-example

Example repository testing vuex with vue-test-utils
JavaScript
52
star
11

testing-vuex-store-example

Testing a Vuex store
JavaScript
48
star
12

example-front-end-test-pyramid-app

An example app demonstrating the front-end pyramid
JavaScript
41
star
13

vue-digital-clock

πŸ•š Simple digital clock built with Vue.js
JavaScript
41
star
14

vue-test-utils-ava-example

An example vue-test-utils project with AVA
JavaScript
30
star
15

mock-vuex-in-vue-unit-tests-tutorial

Example repo demonstrating how to mock Vuex in Vue unit tests
JavaScript
29
star
16

vue-test-utils-karma-example

JavaScript
26
star
17

data-structures-in-practice

Learn about data structures and how they are used in open source projects. https://data-structures-in-practice.com/
SCSS
22
star
18

react-boilerplate

πŸš€ Quickly start a react project with this boilerplate
JavaScript
18
star
19

how-to-unit-test-vue-components-for-beginners

Repo for tutorial on how to test vue components
JavaScript
16
star
20

avoriaz-ava-example

Testing Vue components with AVA and avoriaz example
JavaScript
16
star
21

git-init-plus

⚑ Turbo charged git init
Shell
15
star
22

avoriaz-karma-mocha-example

Example using avoriaz with karma and mocha to test Vue.js components
JavaScript
13
star
23

avoriaz-jest-example

Example project using avoriaz and jest
JavaScript
12
star
24

vue-email-signup-form-app

Demonstration repo
JavaScript
12
star
25

avoriaz-mocha-example

Example using avoriaz with mocha-webpack to test Vue.js components
JavaScript
12
star
26

testing-a-vuex-store-example-app

Example app for testing Vuex
JavaScript
10
star
27

vue-test-utils-tape-example

An example vue-test-utils project with tape
JavaScript
8
star
28

tape-vue-example

JavaScript
8
star
29

vue-jest-example

Example project using Jest
JavaScript
7
star
30

vue-test-loader-example

An example project using vue-test-loader to extract tests
Vue
7
star
31

react-dev-tools-iframe-webpack-plugin

Inject code to set up React dev tools for code running in an iframe
JavaScript
6
star
32

vue-unit-test-starter

Starter project for Vue unit testing tutorials
JavaScript
6
star
33

dom-event-types

DOM event data scraped from MDN
TypeScript
5
star
34

vue-test-utils-mocha-example

An example vue-test-utils project with mocha
JavaScript
5
star
35

conditional-specs

Conditional spec methods for test suites that run in multiple environments
JavaScript
4
star
36

palette-generator

🎨 Webapp that generates color palettes. Built with Vue + Vuex
JavaScript
4
star
37

vue-add-globals

Add globals to a Vue instance 🌎
JavaScript
4
star
38

vue-amsterdam-example

Example from Vue Amsterdam talkβ€”slides.com/eddyerburgh/testing-vue-components
JavaScript
4
star
39

blog

πŸ“• My personal blog
SCSS
3
star
40

vue-test-utils-proposal

Proposed API for vue test utils
3
star
41

stub-route-in-vue-unit-tests

A demonstration of how to stub $route in Vue unit tests
JavaScript
3
star
42

avoriaz-karma-jasmine-example

Simple avoriaz example using karma and jasmine
JavaScript
3
star
43

jest-vue-example

Finished project of Vue Jest
JavaScript
2
star
44

express-mongo-rest-api-boilerplate

An express REST API boilerplate with mongo and mongoose. Dockerized
JavaScript
2
star
45

stub-vue-components-inject-loader

JavaScript
1
star
46

codemods

JavaScript
1
star
47

is-dom-selector

JavaScript function to validate a DOM selector
JavaScript
1
star
48

vue-ios-calculator

Vue IOS calculator app
Vue
1
star
49

palette-picker

A web app that lets you store and copy swatches of color. Built with react + redux
JavaScript
1
star