jest-vue-preprocessor
jest-vue-preprocessor
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
- add package you your project
yarn add --dev jest-vue-preprocessorornpm install --saveDev jest-vue-preprocessor
-
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" } } -
Start writing test that can import
*.vuecomponents - see example ./tests/index.spec.js -
Profit!
Customization
- non-relative component imports - you properly set jest's
moduleMapperoption - see #25
Contributing guide
License: MIT
Related Packages
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 | |
| 1.3.1 | MIT | |
| 1.3.0 | MIT | |
| 1.2.0 | MIT | |
| 1.1.0 | MIT | |
| 1.0.1 | MIT | |
| 1.0.0 | MIT | |
| 0.2.0 | MIT | |
| 0.1.3 | MIT | |
| 0.1.2 | MIT | |
| 0.1.1 | MIT | |
| 0.1.0 | MIT |