vuejs / vue-jest

Jest Vue transformer
MIT License
746 stars 157 forks source link

Coverage report is complaining about non existing lines of code #522

Closed Envoy49 closed 1 year ago

Envoy49 commented 1 year ago

Have an issue after an update, where coverage report is complaining about non existing lines of code. Since I am using NUXT and had to upgrade to the latest NUXT Bridge. Code coverage is complaining about my VUE code files not being covered. Whereas most of them were covered on 100% according to old and correct report.. After an update coverage is complaining about lines which don't exist at all. My overall coverage dropped from 70% to 40% due to this wrong report Below is the screenshot of before and after results.

image

My current package.json

 "dependencies": {
    "nuxt-edge": "latest",
  },

  "devDependencies": {
    "@vue/test-utils": "1.3.3",
    "@vue/vue2-jest": "29.0.0",  
    "vue-template-compiler": "^2.7.14"
  },

My previous package.json:

 "dependencies": {
    "nuxt-edge": "^2.16.0-27358576.777a4b7f",
  },

  "devDependencies": {
    "@vue/test-utils": "^1.2.2",
    "@vue/vue2-jest": "^27.0.0-alpha.4",
  },

Solution from here https://github.com/vuejs/vue-jest/issues/480#issuecomment-1330479635 didn't help in my case

We have so many coverage issues reported long time now and none of them resolved:

https://github.com/vuejs/vue-jest/issues/500 https://github.com/vuejs/vue-jest/issues/488 https://github.com/vuejs/vue-jest/issues/480 https://github.com/vuejs/vue-jest/issues/504 https://github.com/vuejs/vue-jest/issues/514

Envoy49 commented 1 year ago

Upgrading couple of packages and editing jest.config.ts fixed the issue with coverage.

package.json

"@types/jest": "^29.2.2",
"jest": "^29.3.1",
"jest-environment-jsdom": "29.3.1",
"ts-jest": "^29.0.3",

jest.config.ts

  moduleNameMapper: {
    "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
      "<rootDir>/tests/mocks/fileMock.ts",
    uuid: require.resolve("uuid"),
  },
 coverageProvider: "v8",