vuejs / vue-jest

Jest Vue transformer
MIT License
742 stars 159 forks source link

TypeError: Cannot read properties of undefined (reading 'cwd') #520

Open derweise opened 1 year ago

derweise commented 1 year ago

When running:

npm run test:unit --coverage && npm run test:e2e

But I am getting:

 Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'cwd')

      at Object.getCacheKey (node_modules/babel-jest/build/index.js:301:33)

package.json:

"vue": "^3.2.33",

and:

"devDependencies": {
    "@types/jest": "28.1.1",
    "@vue/cli-plugin-babel": "~4.5.15",
    "@vue/cli-plugin-e2e-nightwatch": "^4.5.11",
    "@vue/cli-plugin-eslint": "~4.5.15",
    "@vue/cli-plugin-unit-jest": "~4.5.19",
     ....
    "@vue/test-utils": "2.0.2",
    "@vue/vue3-jest": "^28.1.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.1.0",
    "babel-jest": "^28.1.3",
     .....
    "jest": "^28.1.3",
     ...
  },

and:

"jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "vue"
    ],
    "transform": {
      "^.+\\.vue$": "@vue/vue3-jest",
      ".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
      "^.+\\.js$": "<rootDir>/node_modules/babel-jest"
    },
    "transformIgnorePatterns": [
      "/node_modules/"
    ],
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/src/$1"
    },
    "snapshotSerializers": [
      "jest-serializer-vue"
    ],
    "testMatch": [
      "**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"
    ],
    "testURL": "http://localhost/",
    "watchPlugins": [
      "jest-watch-typeahead/filename",
      "jest-watch-typeahead/testname"
    ],
    "collectCoverageFrom": [
      "src/**/*.{js,vue}",
      "!node_modules/*",
      "!src/main.js",
      "!src/router.js",
      "!src/store/index.js",
      "!src/setup/*"
    ]
  }