Open david-kirkland opened 2 months ago
Having same issue on vite+vue+cypress+jest project: nyc@15.1.0, istanbul-lib-coverage@3.2, jest@29.7.0, vite@5.4.3
Worked around by manually normalizing paths in json coverage data files before running nyc report
.
Link to bug demonstration repository
https://github.com/david-kirkland/ng18-code-coverage/tree/bug-nyc-file-paths
Branch =
bug-nyc-file-paths
Expected Behavior
The generated coverage JSON has consistent file path delimiters.
Observed Behavior
The generated coverage JSON has inconsistent file path delimiters.
Sometimes it uses a forward slash and sometimes it uses a double backslash. This becomes a problem when attempting to merge reports as coverage is not calculated cumulatively when the file paths do not match between reports.
Troubleshooting steps
You will see in the repo that I am attempting to merge component and e2e test coverage reports (via
npm run test:coverage
), both generated by Cypress. I am not saying the file path delimiters differ for component and e2e tests. I'm saying the generated JSON coverage will use different file path delimiters for the same file when re-running the same test type (component or e2e) without any other changes. For example, runnpm run test:component
and sometimes you will get...Re-run
npm run test:component
without making any changes and the next time you might get...Note: I am on a company-issued Windows 10 Enterprise machine.
cache: false
in my nyc config.Environment Information