jest-vue
Version:
Jest Vue transform
70 lines (48 loc) • 1.48 kB
Markdown
Jest Vue transformer with source map support
this package has been renamed to vue-jest
You can download vue-jest with the following command:
```
npm install --save-dev vue-jest
```
```
npm install --save-dev jest-vue
```
To define jest-vue as a transformer for your .vue files, you need to map .vue files to the jest-vue module.
```
"transform": {
".*\\.(vue)$": "<rootDir>/node_modules/jest-vue"
},
```
To use source maps, you need to set `mapCoverage` to `true`. A full config will look like this.
```json
{
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
".*\\.(vue)$": "<rootDir>/node_modules/jest-vue"
},
"mapCoverage": true
}
}
```
Example repositories testing Vue components with jest and jest-vue:
- [Avoriaz with Jest](https://github.com/eddyerburgh/avoriaz-jest-example)
- [Vue Test Utils with Jest](https://github.com/eddyerburgh/vue-test-utils-jest-example)
jest-vue compiles the script and template of SFCs into a JavaScript file that Jest can run. **It does not currently compile the style section**.
- **typescript** (`lang="ts"`, `lang="typescript"`)
- **coffeescript** (`lang="coffee"`, `lang="coffeescript"`)
- **pug** (`lang="pug"`)
- **jade** (`lang="jade"`)