From df2306c02da91f8904deab8799395c4d67cf5cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Fontcuberta?= Date: Tue, 21 Sep 2021 10:50:06 +0200 Subject: [PATCH 1/4] Update README.md --- README.md | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d6d4a88b..d8b009b7 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,32 @@ # vue-jest -Jest transformer for Vue single file components +Jest transformer for Vue Single File Components. -> **NOTE:** This is documentation for `vue-jest@4.x`. [View the vue-jest@3.x documentation](https://github.com/vuejs/vue-jest/tree/v3) +## Installation -## Usage +Since we need to support a variety of Vue and Jest versions, vue-jest don't follow semantic versioning. -```bash -npm install --save-dev vue-jest -yarn add vue-jest --dev -``` - -### Usage with Babel 7 +|Vue version|Jest Version|Package| +|-----------|------------|-------| +|Vue 2|Jest 26 and below|`vue-jest@4`| +|Vue 2|Jest 27|`@vue/vue2-jest@27`| +|Vue 3|Jest 27|`@vue/vue3-jest@27`| -If you use [jest](https://github.com/facebook/jest) > 24.0.0 and [babel-jest](https://github.com/facebook/jest/tree/master/packages/babel-jest) make sure to install babel-core@bridge ```bash -npm install --save-dev babel-core@bridge -yarn add babel-core@bridge --dev +npm install --save-dev @vue/vue2-jest@27 # (use the appropriate version) +yarn add @vue/vue2-jest@27 --dev ``` ## Setup -To use `vue-jest` as a transformer for your `.vue` files, map them to the `vue-jest` module: +To use `vue-jest` as a transformer for your `.vue` files, map them to the appropriate `vue-jest` module: ```json { "jest": { "transform": { - "^.+\\.vue$": "vue-jest" + "^.+\\.vue$": "@vue/vue2-jest" // Update to match your installed version } } } @@ -42,19 +40,22 @@ A full config will look like this. "moduleFileExtensions": ["js", "json", "vue"], "transform": { "^.+\\.js$": "babel-jest", - "^.+\\.vue$": "vue-jest" + "^.+\\.vue$": "@vue/vue2-jest" } } } ``` -## Examples +### Usage with Babel 7 -Example repositories testing Vue components with jest and vue-jest: +If you use [jest](https://github.com/facebook/jest) > 24.0.0 and [babel-jest](https://github.com/facebook/jest/tree/master/packages/babel-jest) make sure to install babel-core@bridge -- [Vue Test Utils with Jest](https://github.com/eddyerburgh/vue-test-utils-jest-example) +```bash +npm install --save-dev babel-core@bridge +yarn add babel-core@bridge --dev +``` -## Supported langs +## Supported languages for SFC sections vue-jest compiles `