Skip to content

Commit 4e917d9

Browse files
authored
chore: update to jest 27 (#811)
* chore: update to jest 27 Updates jest, ts-jest and babel-jest to v27. vue-jest v5 does not support jest v27, so a new vue3-jest package has been introduced (see vuejs/vue-jest#343), with a version number aligned on the jest version (as ts-jest and babel-jest do). This commits replaces vue-jest by vue3-jest, and updates the jest config to use this new trasnformer. This will be the default Vue CLI setup in the future. * chore: document hasOwnProperty Jest workaround
1 parent 67a3e7a commit 4e917d9

File tree

4 files changed

+1253
-2316
lines changed

4 files changed

+1253
-2316
lines changed

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212
},
1313
testEnvironment: 'jsdom',
1414
transform: {
15-
'^.+\\.vue$': 'vue-jest',
15+
'^.+\\.vue$': '@vue/vue3-jest',
1616
'^.+\\js$': 'babel-jest'
1717
},
1818
moduleFileExtensions: ['vue', 'js', 'json', 'jsx', 'ts', 'tsx', 'node'],

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
"@vue/compat": "3.2.31",
2727
"@vue/compiler-dom": "3.2.31",
2828
"@vue/compiler-sfc": "3.2.31",
29-
"babel-jest": "^26.6.3",
30-
"babel-preset-jest": "^27.5.1",
29+
"@vue/vue3-jest": "27.0.0-alpha.4",
30+
"babel-jest": "27.1.0",
31+
"babel-preset-jest": "27.0.6",
3132
"husky": "^7.0.4",
32-
"jest": "25.5.4",
33+
"jest": "27.5.1",
3334
"jsdom": "^19.0.0",
3435
"jsdom-global": "^3.0.2",
3536
"lint-staged": "^12.3.3",
@@ -38,7 +39,7 @@
3839
"reflect-metadata": "^0.1.13",
3940
"rollup": "^2.67.2",
4041
"rollup-plugin-typescript2": "^0.31.2",
41-
"ts-jest": "25.3.1",
42+
"ts-jest": "27.1.3",
4243
"tslib": "2.3.1",
4344
"typescript": "4.5.5",
4445
"vitepress": "^0.22.0",

src/mount.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ export function mount(
507507
console.warn = () => {}
508508

509509
const appRef = vm.$refs[MOUNT_COMPONENT_REF] as ComponentPublicInstance
510-
// we add `hasOwnProperty` so jest can spy on the proxied vm without throwing
510+
// we add `hasOwnProperty` so Jest can spy on the proxied vm without throwing
511+
// note that this is not necessary with Jest v27+ or Vitest, but is kept for compatibility with older Jest versions
511512
appRef.hasOwnProperty = (property) => {
512513
return Reflect.has(appRef, property)
513514
}

0 commit comments

Comments
 (0)