Jest Vue transformer for Vue 3.
npm install --save-dev vue-jest
yarn add --dev vue-jest
To define vue-jest
as a transformer for your .vue
files, map them to the vue-jest
module:
{
"jest": {
"transform": {
"^.+\\.vue$": "vue-jest"
}
}
Example repositories testing Vue 3 components with jest and vue-jest:
TODO: Examples
vue-jest compiles the script and template of SFCs into a JavaScript file that Jest can run.
- typescript (
lang="ts"
,lang="typescript"
) - coffeescript (
lang="coffee"
,lang="coffeescript"
)
-
pug (
lang="pug"
)- To give options for the Pug compiler, enter them into the Jest configuration. The options will be passed to pug.compile().
{ "jest": { "globals": { "vue-jest": { "pug": { "basedir": "mybasedir" } } } } }
You can change the behavior of vue-jest
by using jest.globals
.
- Style support
- Custom blocks
- Global config