vuejs / vue-jest

Jest Vue transformer
MIT License
746 stars 157 forks source link

TypeError: Cannot read properties of undefined (reading 'getCacheKey') #442

Open MarkTallentire opened 2 years ago

MarkTallentire commented 2 years ago

My package.json:

 "devDependencies": {
    "@babel/eslint-parser": "^7.13.14",
    "@quasar/app": "^3.2.9",
    "@quasar/quasar-app-extension-testing": "^2.0.2",
    "@quasar/quasar-app-extension-testing-e2e-cypress": "^4.0.0-beta.9",
    "@quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-alpha.8",
    "@testing-library/dom": "^8.11.1",
    "@testing-library/user-event": "^13.5.0",
    "@testing-library/vue": "^6.4.2",
    "@types/node": "^12.20.21",
    "@typescript-eslint/eslint-plugin": "^4.16.1",
    "@typescript-eslint/parser": "^4.16.1",
    "@vue/vue3-jest": "^27.0.0-alpha.3",
    "babel-core": "^7.0.0-bridge.0",
    "concurrently": "^6.3.0",
    "electron": "^16.0.6",
    "eslint": "^7.14.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-cypress": "^2.11.3",
    "eslint-plugin-jest": "^25.2.2",
    "eslint-plugin-vue": "^7.0.0",
    "jest": "^27.4.7",
    "jest-cli": "^27.4.7",
    "majestic": "^1.7.0",
    "ts-jest": "^27.1.3"
  },

Error thrown: TypeError: Cannot read properties of undefined (reading 'getCacheKey')

Unsure if this is because Jest 27 is still not fully supported?

christianlmc commented 2 years ago

I'm facing the same issue with @vue/vue2-jest on Vue 2. I think they need to update the following line

node_modules/@vue/vue2-jest/lib/index.js

const babelJest = require('babel-jest').default // Returns undefined
littlejon85 commented 2 years ago

Faced this error when trying to collect test coverage. Installing babel-jest": "^27.5.1" fixed this for me.

fwx5618177 commented 2 years ago

New version patch has solved this questions. If use vue3, need to use these version could solve it.

{
    "babel-jest": "^29.0.2",
    "jest": "^29.0.2",
    "jest-environment-jsdom": "^29.0.2",
    "jest-environment-node": "^29.0.2",
   "ts-jest": "^28.0.8",
    "@vue/vue3-jest": "^29.0.0"
}