Jest Vue Preprocessor

1.7.1 · abandoned · verified Tue Apr 21

jest-vue-preprocessor is a Jest transformer designed to enable the testing of Vue Single File Components (SFCs) within a Jest environment. Specifically, it allows Jest to correctly parse and process `.vue` files by transforming their templates and scripts into a format Jest can understand, supporting both ES6 (via Babel) and TypeScript. The current stable version is 1.7.1. This package was largely based on `vueify` and aimed to bridge the gap for Vue 2 projects wanting to use Jest for unit testing. Its primary differentiation is providing out-of-the-box support for `.vue` file compilation within Jest's isolated test environment, which Jest does not handle natively. However, it is an older package, last updated in 2019, and is primarily compatible with Vue 2.x and specific older versions of `vue-template-compiler`. Newer Vue projects (Vue 3 and above) typically use `vue-jest` for their testing needs due to significant breaking changes in Vue's compilation pipeline. Given its age and lack of recent updates, its release cadence is effectively ceased, and it should be considered abandoned for new projects.

Common errors

Warnings

Install

Imports

Quickstart

This configuration snippet shows how to integrate `jest-vue-preprocessor` into your `package.json`'s Jest settings, enabling Jest to process `.vue` files and use Babel for JavaScript transformation.

{
  "jest": {
    "moduleFileExtensions": [
      "js",
      "vue"
    ],
    "mapCoverage": true,
    "transform": {
      "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
      ".*\\.(vue)$": "<rootDir>/node_modules/jest-vue-preprocessor"
    }
  }
}

view raw JSON →