jest-vue-preprocessor

Preprocessor that allows importing of .vue files in jest tests
482,517 128
Install
npm install jest-vue-preprocessor
Latest Version:1.7.1
Vue:2
License:MIT
Last Updated:Dec 8, 2022
Links: GitHub  ·  npm
Maintainer: vire

jest-vue-preprocessor

Greenkeeper badge 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

Related Packages

jest-matcher-vue-test-utils

Jest matchers to test Vue components easily

8,429 34
jest-serializer-vue

A jest serializer for Vue snapshots

15,648,486 63
@forsakringskassan/jest-config-vue

Shareable jest configuration for vue applications

137,449 0
@fkui/test-utils

FKUI test utils for Jest och Vitest

14,898 56
anima-vue-scroller

Vue scroller picke anima-vue-scroller

1,656 0

Version History

Version Released License
1.7.1 MIT
1.7.0 MIT
1.6.0 MIT
1.5.0 MIT
1.4.0 MIT