0.4.1 • Published 6 years ago

vue-test-loader v0.4.1

Weekly downloads
39
License
MIT
Repository
github
Last release
6 years ago

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

NameDescriptionDefault
extensionstring 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

0.4.1

6 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago