Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support jest 28 #468

Merged
merged 5 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ 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 | Package |
| ----------- | ----------------- | ------------------- |
| 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@xx` |
| Vue 3 | Jest 27 and above | `@vue/vue3-jest@xx` |

**xx**: Major version of Jest

```bash
npm install --save-dev @vue/vue2-jest # (use the appropriate version)
Expand Down
7 changes: 4 additions & 3 deletions e2e/2.x/babel-in-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
"@vue/test-utils": "^1.1.0",
"@vue/vue2-jest": "~27.0.0-alpha.1",
"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",
Expand Down
7 changes: 4 additions & 3 deletions e2e/2.x/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
"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",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue2-jest": "~27.0.0-alpha.1"
},
"jest": {
Expand Down
5 changes: 3 additions & 2 deletions e2e/2.x/custom-transformers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"@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",
Expand Down
2 changes: 1 addition & 1 deletion e2e/2.x/style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@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",
Expand Down
7 changes: 4 additions & 3 deletions e2e/3.x/babel-in-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"@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",
"jest": "^28.0.0",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^27.0.0-alpha.1"
},
"jest": {
Expand Down
7 changes: 4 additions & 3 deletions e2e/3.x/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"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-property-decorator": "^10.0.0-rc.3"
Expand Down
3 changes: 2 additions & 1 deletion e2e/3.x/custom-block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"@babel/preset-env": "^7.9.0",
"@vue/compiler-sfc": "^3.0.3",
"@vue/vue3-jest": "^27.0.0-alpha.1",
"jest": "^27.0.0"
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2"
},
"jest": {
"moduleFileExtensions": [
Expand Down
5 changes: 3 additions & 2 deletions e2e/3.x/custom-transformers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"@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",
"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"
Expand Down
3 changes: 2 additions & 1 deletion e2e/3.x/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"coffeescript": "^2.3.2",
"jest": "^27.0.0",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"@vue/vue3-jest": "^27.0.0-alpha.1"
},
"jest": {
Expand Down
3 changes: 2 additions & 1 deletion e2e/3.x/style/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"@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",
Expand Down
7 changes: 4 additions & 3 deletions e2e/3.x/typescript-with-babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"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",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^27.0.0-alpha.1"
},
"jest": {
Expand Down
7 changes: 4 additions & 3 deletions e2e/3.x/typescript-with-compiler-options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
},
"devDependencies": {
"@types/jest": "16.0.10",
"jest": "^27.0.0",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^27.0.0-alpha.1"
},
"jest": {
Expand Down
7 changes: 4 additions & 3 deletions e2e/3.x/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
},
"devDependencies": {
"@types/jest": "16.0.10",
"jest": "^27.0.0",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"jest": "^28.0.2",
"jest-environment-jsdom": "28.0.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"@vue/vue3-jest": "^27.0.0-alpha.1"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue2-jest/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
return crypto
.createHash('md5')
.update(
babelJest.getCacheKey(fileData, filename, {
babelJest.createTransformer().getCacheKey(fileData, filename, {
config,
configString,
instrument,
Expand Down
2 changes: 1 addition & 1 deletion packages/vue2-jest/lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vue2-jest/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 10 additions & 7 deletions packages/vue2-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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
Expand Up @@ -10,7 +10,7 @@ module.exports = {
return crypto
.createHash('md5')
.update(
babelJest.getCacheKey(fileData, filename, {
babelJest.createTransformer().getCacheKey(fileData, filename, {
config,
configString,
instrument,
Expand Down
2 changes: 1 addition & 1 deletion packages/vue3-jest/lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vue3-jest/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 12 additions & 9 deletions packages/vue3-jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@
"devDependencies": {
"@babel/core": "^7.9.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^27.0.0",
"babel-jest": "^28.0.2",
"conventional-changelog": "^1.1.5",
"jest": "^27.0.0",
"jest-cli": "^27.0.0",
"jest": "^28.0.2",
"jest-cli": "^28.0.2",
"semantic-release": "^15.13.2",
"ts-jest": "^27.0.1",
"typescript": "^4.1.2",
"ts-jest": "^28.0.1",
"typescript": "^4.6.4",
"vue": "^3.2.22"
},
"peerDependencies": {
"@babel/core": "7.x",
"babel-jest": "27.x",
"jest": "27.x",
"ts-jest": "27.x",
"typescript": ">= 3.x",
"babel-jest": "28.x",
"jest": "28.x",
"ts-jest": "28.x",
"typescript": ">= 4.3",
"vue": "^3.0.0-0"
},
"peerDependenciesMeta": {
Expand Down Expand Up @@ -73,5 +73,8 @@
"yarn format",
"git add"
]
},
"engines": {
"node": ">10"
}
}
Loading