quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+
https://testing.quasar.dev
MIT License
179 stars 65 forks source link

Not instrumented files in coverage report #319

Closed radoslavirha closed 1 year ago

radoslavirha commented 1 year ago

Hi,

In my quasar, ts, vite app I want to get real coverage from e2e+component tests. It seems to be an issue somewhere in cypress or @quasar/quasar-app-extension-testing-e2e-cypress. I successfully modified .nycrc to report all the files, but in report there are components with 0 and my final result is not real coverage.

I think it is similar to https://github.com/cypress-io/cypress/issues/17230, but I'm not sure how to implement it in quasar dev server injected to cypress.

Software version

"@quasar/app-vite": "^1.2.0",
"@quasar/quasar-app-extension-testing": "^2.0.6",
"@quasar/quasar-app-extension-testing-e2e-cypress": "^5.0.0-beta.11",
"@quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-beta.5",
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.1.2",

OS: macos Node: 18 NPM: 9.4.1 Any other software related to your bug:

What did you get as the error?

image

What were you expecting?

Instrument untested components to see real coverage ...now I'm getting almost 100% but only from few tested components

What steps did you take, to get the error?

I just followed docs how to run e2e, component and unit tests

IlCallo commented 1 year ago

I'm not sure I understood your problem, you setup nyc to cover also untested components and not you get 0% coverage for them? That's the expected behaviour I guess Or do you mean that components with 0% aren't considered in calculating the overall testing coverage? IIRC that's by design, either by Istanbul plugin or NYC

In any case, I'd suggest you to check out https://github.com/iFaxity/vite-plugin-istanbul/issues or NYC and open an issue there if you need help We're not experts in that area and the maintainer of those projects know best about how to configure them for sure

radoslavirha commented 1 year ago

Hi,

Or do you mean that components with 0% aren't considered in calculating the overall testing coverage? exactly.

I'm not sure where is the issue, but if I switch vitest (unit tests) to use istanbul instead of default c8, I can see not covered files but are considered in calculating the overall testing coverage. So I'm not sure if it's istanbul issue.

Visually there are red zeros in unit tests coverage. And it's from istanbul.

image

Back to component tests, in .nyc_output/out.json there are not instumented? files:

"someComponent.vue": {
  "path": "someComponent.vue",
  "statementMap": {},
  "fnMap": {},
  "branchMap": {},
  "s": {},
  "f": {},
  "b": {}
}

and ^^ is the issue I think and istanbul does not get number of lines and other data, so the lines in report are white, thus not considered for final result.

I saw all the related issues on github and cloned this repo but I wasn't able to get correct numbers in .nyc_output/out.json

I'm still 'user' of this utils, so I'm not sure If I can identify where the problem is. My research is described ^^.

If you can help me I can play with this repo again

IlCallo commented 1 year ago

I'm sorry, but my knowledge of Istanbul isn't that good, that's why I don't really know how to help either I know I hit the same or similar problem before and couldn't find a way to get it working at that time I also know there are some problems with Vue3 which the maintainer of vite-plugin-istanbul wasn't able to resolve, but I don't have the time to explore those and fix it in the upstream project That's why I told you to check the issues on that repo and ask the maintainer of the plugin directly

radoslavirha commented 1 year ago

@IlCallo I opened new issue in vite-plugin-istanbul, maybe you want to watch it too. I can help you with debugging some bugs in this repo, but I have no deep experience with cypress,...

https://github.com/iFaxity/vite-plugin-istanbul/issues/78#issue-1585588664