bahmutov/cypress-and-jest

Different folder level between Jest and Cypress

eric-burel opened this issue · 2 comments

Hi,

When running unit coverage and e2e coverage, my reports are not at the same level:

coverage-unit > lcov-report > my-app-name > my code # Jest
coverage-e2e> lcov-report > my code # Cypress

Do you have any idea how to configure either Cypress or Jest to use the same l`evel (the easiest to configure probably being Jest)?

Also I hit Cannot read property 'loc' of undefined error when running nyc report --reporter lcov --report-dir coverage but that's probably a different issue.

Thanks a lot for all your config examples, I have managed to setup Cypress coverage in a TS + Next project, which was very tricky. I am at the last step of merging Jest and Cypress and very eager to see the result!

Edit: I also seem to have different line counts/branch counts between them.

Specifically for the difference in folder level, I ended up putting my code in a specific src/ folder (in a Next app). Putting code at the project's root will provoke differences between Cypress and Jest.

However line counts are still wrong somehow. This is because I use TypeScript, my best guess is that in Jest sourcemaps are created on transpiled code and not in Cypress (or the other way around, I don't know yet).

Note that even if yc report --reporter lcov --report-dir coverage fails, I still have a working coverage folder, is this normal? The values are false however due to the line number discrepencies between each tools.

I would think you need to update the produced JSON coverage results before reporting them yourself. They are just JSON files so you can load them, change names and paths and save back - and then all should be good.