失败tests/Unit/example.spec.js ●测试套件运行失败
TypeError: Cannot read properties of undefined (reading 'getCacheKey')
at Object.getCacheKey (node_modules/vue3-jest/lib/index.js:13:19)
- ————————-|- ————————-|- ————————-|- ————————-|- ————————-|- —————————————————-|档案|%状态|分支百分比|函数百分比|%行|未覆盖行号|--|- ————————-|- ————————-|- ————————-|- ————————-|- —————————————————-|所有档案|第0页|第0页|第0页|第0页||--|- ————————-|- ————————-|- ————————-|- ————————-|- —————————————————-|测试套件:1次失败,共1次测试:共0个快照:0总计时间:1.544s运行所有测试套件。
package.json
"devDependencies": {
"@inertiajs/inertia": "^0.8.4",
"@inertiajs/inertia-vue3": "^0.3.5",
"@inertiajs/progress": "^0.2.4",
"@tailwindcss/forms": "^0.2.1",
"@tailwindcss/typography": "^0.3.0",
"@vue/cli-plugin-unit-jest": "~4.5.0",
"@vue/cli-service": "^4.5.15",
"@vue/compiler-sfc": "^3.0.5",
"@vue/test-utils": "^2.0.0-0",
"axios": "^0.21.1",
"babel-jest": "^22.4.3",
"flush-promises": "^1.0.2",
"jest": "^27.3.1",
"laravel-mix": "^6.0.6",
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"postcss-import": "^12.0.1",
"tailwindcss": "^2.0.1",
"typescript": "~3.9.3",
"vue": "^3.0.5",
"vue-loader": "^16.1.2",
"vue3-jest": "^27.0.0-alpha.1"
}
jest.config.js
const config = {
preset: '@vue/cli-plugin-unit-jest',
collectCoverage: true,
transform: {
'^.+\\.vue$': 'vue3-jest',
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest'
},
testMatch:["**/tests/Unit/*.spec.[jt]s?(x)"],
verbose: true,
};
有什么主意吗?谢谢
1条答案
按热度按时间lmyy7pcs1#
我也遇到了同样的问题,对我来说,将
babel-jest
更新到最新版本(27. 5. 1)修复了这个问题。