jest-vue-preprocessor-wsm

1.2.0 • Public • Published

jest-vue-preprocessor

Build Status npm version codecov Commitizen friendly

A locoslab/vue-typescript-jest JavaScript port to allow Jest load .vue files in tests. This package supports both ES6 (Babel) and TypeScript.

Portions both preprocessors are heavily based vueify (Copyright (c) 2014-2016 Evan You).

Installation

  1. add package you your project
  • yarn add --dev jest-vue-preprocessor or npm install --saveDev jest-vue-preprocessor
  1. modify package.json's jest section by adding/editing moduleFileExtensions and transform properites:

    "jest": {
      "moduleFileExtensions": [
        "js",
        "vue"
      ],
      "mapCoverage": true,
      "transform": {
        "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
        ".*\\.(vue)$": "<rootDir>/node_modules/jest-vue-preprocessor"
      }
    }
  2. Start writing test that can import *.vue components - see example ./tests/index.spec.js

  3. Profit!

### Customization

  • non-relative component imports - you properly set jest's moduleMapper option - see #25

### Contributing guide

### License: MIT

Package Sidebar

Install

npm i jest-vue-preprocessor-wsm

Weekly Downloads

1

Version

1.2.0

License

MIT

Last publish

Collaborators

  • xiphe