|  | ||||
|---|---|---|---|---|
| .. | ||||
| .circleci | 11e3a9652a | 7 年之前 | ||
| build | 11e3a9652a | 7 年之前 | ||
| lib | 11e3a9652a | 7 年之前 | ||
| node_modules | 11e3a9652a | 7 年之前 | ||
| test | 11e3a9652a | 7 年之前 | ||
| .babelrc | 11e3a9652a | 7 年之前 | ||
| .eslintignore | 11e3a9652a | 7 年之前 | ||
| .eslintrc | 11e3a9652a | 7 年之前 | ||
| CHANGELOG.md | 11e3a9652a | 7 年之前 | ||
| LICENSE | 11e3a9652a | 7 年之前 | ||
| README.md | 11e3a9652a | 7 年之前 | ||
| package.json | 11e3a9652a | 7 年之前 | ||
| test.sh | 11e3a9652a | 7 年之前 | ||
| tsconfig.json | 11e3a9652a | 7 年之前 | ||
| vue-jest.js | 11e3a9652a | 7 年之前 | ||
Jest Vue transformer with source map support
npm install --save-dev vue-jest
To define vue-jest as a transformer for your .vue files, you need to map .vue files to the vue-jest module.
"transform": {
  ".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
},
To use source maps, you need to set mapCoverage to true. A full config will look like this.
{
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "vue"
    ],
    "transform": {
      "^.+\\.js$": "<rootDir>/node_modules/babel-jest",
      ".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
    },
    "mapCoverage": true
  }
}
Example repositories testing Vue components with jest and vue-jest:
vue-jest compiles the script and template of SFCs into a JavaScript file that Jest can run. It does not currently compile the style section.
lang="ts", lang="typescript")lang="coffee", lang="coffeescript")lang="pug")lang="jade")lang="haml")