Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nyc generates inconsistent file delimiters #1575

Open
david-kirkland opened this issue Jul 22, 2024 · 1 comment
Open

nyc generates inconsistent file delimiters #1575

david-kirkland opened this issue Jul 22, 2024 · 1 comment

Comments

@david-kirkland
Copy link

david-kirkland commented Jul 22, 2024

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.

image
image

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, run npm run test:component and sometimes you will get...

image

Re-run npm run test:component without making any changes and the next time you might get...

image

Note: I am on a company-issued Windows 10 Enterprise machine.

  • The bug still occurs when I put cache: false in my nyc config.

Environment Information

  System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1365U
    Memory: 13.74 GB / 31.64 GB
  Binaries:
    Node: 22.4.1 - ~\AppData\Local\fnm_multishells\11776_1721413704500\node.EXE
    npm: 10.8.1 - ~\AppData\Local\fnm_multishells\11776_1721413704500\npm.CMD
  npmPackages:
    @jsdevtools/coverage-istanbul-loader: 3.0.5 => 3.0.5
    istanbul-lib-coverage: 3.2.2 => 3.2.2
    nyc: 17.0.0 => 17.0.0
    source-map-support: ^0.5.21 => 0.5.21
    ts-node: ^10.9.2 => 10.9.2
    typescript: 5.5.3 => 5.5.3
@pawelgur
Copy link

pawelgur commented Oct 15, 2024

Having same issue on vite+vue+cypress+jest project: [email protected], [email protected], [email protected], [email protected]

Worked around by manually normalizing paths in json coverage data files before running nyc report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants