Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/vue-jest
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v27.0.0
Choose a base ref
...
head repository: vuejs/vue-jest
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v28.0.0
Choose a head ref
  • 3 commits
  • 25 files changed
  • 4 contributors

Commits on May 2, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e2c7a56 View commit details

Commits on May 17, 2022

  1. feat: Support jest 28 (#468)

    * Support Jest 28
    
    fixes #467
    
    [BREAKING CHANGE]: Drop support for jest 27
    
    * Update ts-jest to use latest version
    
    * Update Typescript
    
    * Drop support for Node 10
    
    Jest 28 dropped Node 10 support as well
    
    * Update Readme
    
    Co-authored-by: Valentin Palkovič <valentin.palkovic.extern@elinvar.de>
    valentinpalkovic and Valentin Palkovič authored May 17, 2022
    Copy the full SHA
    d8568cb View commit details
  2. chore: release Jest 28 support (#472)

    * chore: release Jest 28 support
    
    * chore: bump deps
    lmiller1990 authored May 17, 2022
    Copy the full SHA
    f75662d View commit details
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,16 +6,23 @@ Jest transformer for Vue Single File Components.

Since we need to support a variety of Vue and Jest versions, vue-jest doesn't follow semantic versioning.

| Vue version | Jest Version | Package |
| ----------- | ----------------- | ---------------- |
| Vue 2 | Jest 26 and below | `vue-jest@4` |
| Vue 3 | Jest 26 and below | `vue-jest@5` |
| Vue 2 | Jest 27 | `@vue/vue2-jest` |
| Vue 3 | Jest 27 | `@vue/vue3-jest` |
| Vue version | Jest Version | npm Package | Branch |
| ----------- | ----------------- | ------------------- | ------ |
| Vue 2 | Jest 26 and below | `vue-jest@4` | |
| Vue 3 | Jest 26 and below | `vue-jest@5` | |
| Vue 2 | Jest 27 and above | `@vue/vue2-jest@27` | 27.x |
| Vue 3 | Jest 27 and above | `@vue/vue3-jest@27` | 27.x |
| Vue 2 | Jest 28 and above | `@vue/vue2-jest@28` | 28.x |
| Vue 3 | Jest 27 and above | `@vue/vue3-jest@28` | 28.x |

```bash
npm install --save-dev @vue/vue2-jest # (use the appropriate version)
yarn add @vue/vue2-jest --dev
# Vue 2
npm install --save-dev @vue/vue2-jest@28 # (use the appropriate version)
yarn add @vue/vue2-jest@28 --dev

# Vue 3
npm install --save-dev @vue/vue3-jest@28 # (use the appropriate version)
yarn add @vue/vue3-jest@28 --dev
```

## Setup
9 changes: 5 additions & 4 deletions e2e/2.x/babel-in-package/package.json
Original file line number Diff line number Diff line change
@@ -16,11 +16,12 @@
"@babel/preset-env": "^7.9.0",
"@vue/babel-preset-jsx": "^1.2.4",
"@vue/test-utils": "^1.1.0",
"@vue/vue2-jest": "~27.0.0-alpha.1",
"@vue/vue2-jest": "^28.0.0",
"coffeescript": "^2.3.2",
"jest": "27.x",
"ts-jest": "^27.0.4",
"typescript": "^3.2.2"
"jest": "28.x",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4"
},
"jest": {
"testEnvironment": "jsdom",
9 changes: 5 additions & 4 deletions e2e/2.x/basic/package.json
Original file line number Diff line number Diff line change
@@ -19,12 +19,13 @@
"babel-plugin-transform-vue-jsx": "^3.7.0",
"coffeescript": "^2.3.2",
"jade": "^1.11.0",
"jest": "27.x",
"jest": "28.x",
"jest-environment-jsdom": "28.0.2",
"pug": "^3.0.1",
"sass": "^1.23.7",
"ts-jest": "^27.0.4",
"typescript": "^3.2.2",
"@vue/vue2-jest": "~27.0.0-alpha.1"
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue2-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
7 changes: 4 additions & 3 deletions e2e/2.x/custom-transformers/package.json
Original file line number Diff line number Diff line change
@@ -14,12 +14,13 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@vue/test-utils": "^1.1.0",
"babel-jest": "^27.0.6",
"jest": "27.x",
"babel-jest": "^28.0.2",
"jest": "28.x",
"jest-environment-jsdom": "28.0.2",
"postcss": "^7.0.13",
"postcss-color-function": "^4.0.1",
"sass": "^1.23.7",
"@vue/vue2-jest": "~27.0.0-alpha.1"
"@vue/vue2-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
4 changes: 2 additions & 2 deletions e2e/2.x/style/package.json
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@vue/test-utils": "^1.1.0",
"jest": "27.x",
"jest": "28.x",
"less": "^3.9.0",
"postcss": "^7.0.13",
"sass": "^1.23.7",
"stylus": "^0.54.5",
"@vue/vue2-jest": "~27.0.0-alpha.1"
"@vue/vue2-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
9 changes: 5 additions & 4 deletions e2e/3.x/babel-in-package/package.json
Original file line number Diff line number Diff line change
@@ -13,10 +13,11 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"coffeescript": "^2.3.2",
"jest": "^27.0.0",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"@vue/vue3-jest": "^27.0.0-alpha.1"
"jest": "^28.0.0",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
9 changes: 5 additions & 4 deletions e2e/3.x/basic/package.json
Original file line number Diff line number Diff line change
@@ -17,12 +17,13 @@
"babel-plugin-transform-vue-jsx": "^3.7.0",
"coffeescript": "^2.3.2",
"jade": "^1.11.0",
"jest": "^27.0.0",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"pug": "^2.0.3",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"vue-class-component": "^8.0.0-beta.4",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"@vue/vue3-jest": "^28.0.0",
"vue-property-decorator": "^10.0.0-rc.3"
}
}
5 changes: 3 additions & 2 deletions e2e/3.x/custom-block/package.json
Original file line number Diff line number Diff line change
@@ -13,8 +13,9 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@vue/compiler-sfc": "^3.0.3",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"jest": "^27.0.0"
"@vue/vue3-jest": "^28.0.0",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2"
},
"jest": {
"moduleFileExtensions": [
7 changes: 4 additions & 3 deletions e2e/3.x/custom-transformers/package.json
Original file line number Diff line number Diff line change
@@ -13,10 +13,11 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@vue/test-utils": "^2.0.0-rc.10",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"babel-jest": "^27.0.0",
"@vue/vue3-jest": "^28.0.0",
"babel-jest": "^28.0.2",
"css-tree": "^2.0.1",
"jest": "^27.0.0",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"postcss": "^7.0.13",
"postcss-color-function": "^4.0.1",
"sass": "^1.23.7"
5 changes: 3 additions & 2 deletions e2e/3.x/javascript/package.json
Original file line number Diff line number Diff line change
@@ -13,8 +13,9 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"coffeescript": "^2.3.2",
"jest": "^27.0.0",
"@vue/vue3-jest": "^27.0.0-alpha.1"
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"@vue/vue3-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
5 changes: 3 additions & 2 deletions e2e/3.x/style/package.json
Original file line number Diff line number Diff line change
@@ -13,12 +13,13 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"@vue/test-utils": "^2.0.0-rc.10",
"jest": "^27.0.0",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"less": "^3.9.0",
"postcss": "^7.0.13",
"sass": "^1.23.7",
"stylus": "^0.54.5",
"@vue/vue3-jest": "^27.0.0-alpha.1"
"@vue/vue3-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
9 changes: 5 additions & 4 deletions e2e/3.x/typescript-with-babel/package.json
Original file line number Diff line number Diff line change
@@ -12,10 +12,11 @@
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"jest": "^27.0.0",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"@vue/vue3-jest": "^27.0.0-alpha.1"
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
9 changes: 5 additions & 4 deletions e2e/3.x/typescript-with-compiler-options/package.json
Original file line number Diff line number Diff line change
@@ -11,10 +11,11 @@
},
"devDependencies": {
"@types/jest": "16.0.10",
"jest": "^27.0.0",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"@vue/vue3-jest": "^27.0.0-alpha.1"
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
9 changes: 5 additions & 4 deletions e2e/3.x/typescript/package.json
Original file line number Diff line number Diff line change
@@ -11,10 +11,11 @@
},
"devDependencies": {
"@types/jest": "16.0.10",
"jest": "^27.0.0",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"@vue/vue3-jest": "^27.0.0-alpha.1"
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^28.0.0"
},
"jest": {
"testEnvironment": "jsdom",
2 changes: 1 addition & 1 deletion packages/vue2-jest/lib/index.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ module.exports = {
return crypto
.createHash('md5')
.update(
babelJest.getCacheKey(fileData, filename, {
babelJest.createTransformer().getCacheKey(fileData, filename, {
config,
configString,
instrument,
2 changes: 1 addition & 1 deletion packages/vue2-jest/lib/process.js
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ function resolveTransformer(lang = 'js', vueJestConfig) {
} else if (/^coffee$|coffeescript$/.test(lang)) {
return transformer || coffeescriptTransformer
} else {
return transformer || babelTransformer
return transformer || babelTransformer.createTransformer()
}
}

3 changes: 1 addition & 2 deletions packages/vue2-jest/lib/transformers/typescript.js
Original file line number Diff line number Diff line change
@@ -21,8 +21,7 @@ module.exports = scriptLang => ({

res.outputText = stripInlineSourceMap(res.outputText)

const inputSourceMap =
res.sourceMapText !== undefined ? JSON.parse(res.sourceMapText) : ''
const inputSourceMap = res.sourceMapText && JSON.parse(res.sourceMapText)

const customTransformer =
getCustomTransformer(vueJestConfig['transform'], 'js') || {}
2 changes: 1 addition & 1 deletion packages/vue2-jest/lib/utils.js
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ const getBabelOptions = function loadBabelOptions(filename, options = {}) {
}

const getTsJestConfig = function getTsJestConfig(config) {
const { ConfigSet } = require('ts-jest/dist/config/config-set')
const { ConfigSet } = require('ts-jest/dist/legacy/config/config-set')
const configSet = new ConfigSet(config.config)
var tsConfig = configSet.typescript || configSet.parsedTsConfig
return {
19 changes: 11 additions & 8 deletions packages/vue2-jest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue/vue2-jest",
"version": "27.0.0",
"version": "28.0.0",
"description": "Jest transformer for Vue 2",
"main": "lib/index.js",
"files": [
@@ -28,20 +28,20 @@
"@babel/preset-env": "^7.9.0",
"@vue/test-utils": "^1.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^27.0.6",
"babel-jest": "^28.0.2",
"conventional-changelog": "^1.1.5",
"jest": "^27.0.6",
"jest": "^28.0.2",
"semantic-release": "^15.13.2",
"ts-jest": "^27.0.4",
"typescript": "^3.2.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"vue": "^2.4.2",
"vue-template-compiler": "^2.4.2"
},
"peerDependencies": {
"@babel/core": "7.x",
"babel-jest": ">= 27 < 28",
"jest": "27.x",
"ts-jest": ">= 27 < 28",
"babel-jest": ">= 28 < 29",
"jest": "28.x",
"ts-jest": ">= 28 < 29",
"vue": "^2.x",
"vue-template-compiler": "^2.x"
},
@@ -71,5 +71,8 @@
"yarn format",
"git add"
]
},
"engines": {
"node": ">10"
}
}
2 changes: 1 addition & 1 deletion packages/vue3-jest/lib/index.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ module.exports = {
return crypto
.createHash('md5')
.update(
babelJest.getCacheKey(fileData, filename, {
babelJest.createTransformer().getCacheKey(fileData, filename, {
config,
configString,
instrument,
2 changes: 1 addition & 1 deletion packages/vue3-jest/lib/process.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ function resolveTransformer(lang = 'js', vueJestConfig) {
} else if (/^coffee$|coffeescript$/.test(lang)) {
return transformer || coffeescriptTransformer
} else {
return transformer || babelTransformer
return transformer || babelTransformer.createTransformer()
}
}

3 changes: 1 addition & 2 deletions packages/vue3-jest/lib/transformers/typescript.js
Original file line number Diff line number Diff line change
@@ -21,8 +21,7 @@ module.exports = {

res.outputText = stripInlineSourceMap(res.outputText)

const inputSourceMap =
res.sourceMapText !== undefined ? JSON.parse(res.sourceMapText) : ''
const inputSourceMap = res.sourceMapText && JSON.parse(res.sourceMapText)

const customTransformer =
getCustomTransformer(vueJestConfig['transform'], 'js') || {}
2 changes: 1 addition & 1 deletion packages/vue3-jest/lib/utils.js
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ const getTsJestConfig = function getTsJestConfig(config) {
return null
}

const { ConfigSet } = require('ts-jest/dist/config/config-set')
const { ConfigSet } = require('ts-jest/dist/legacy/config/config-set')
const configSet = new ConfigSet(config.config)
const tsConfig = configSet.typescript || configSet.parsedTsConfig
// Force es5 to prevent const vue_1 = require('vue') from conflicting
Loading