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

Ignore code coverage #2491

Closed
6 tasks done
freakzlike opened this issue Dec 12, 2022 · 3 comments · Fixed by #2496
Closed
6 tasks done

Ignore code coverage #2491

freakzlike opened this issue Dec 12, 2022 · 3 comments · Fixed by #2496
Labels
feat: coverage Issues and PRs related to the coverage feature pr welcome

Comments

@freakzlike
Copy link

Describe the bug

After updating vitest from 0.25.4 to 0.25.7 the ignore comments for code coverage /* istanbul ignore if -- @preserve */ are no longer working. Running npm run test within the reproduction with 0.25.7 will have uncovered lines. With 0.25.4 there are none.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-cg758y?file=test/basic.test.ts&view=editor

System Info

System:
    OS: Linux 5.4 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (5) x64 AMD Ryzen 5 4500U with Radeon Graphics
    Memory: 2.95 GB / 6.79 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    npm: 8.19.3 - ~/dev/frontend-utils/node_modules/.bin/npm
  npmPackages:
    @vitejs/plugin-vue: 4.0.0 => 4.0.0
    vite: 4.0.0 => 4.0.0
    vitest: 0.25.7 => 0.25.7

Used Package Manager

pnpm

Validations

@sheremet-va sheremet-va added the feat: coverage Issues and PRs related to the coverage feature label Dec 12, 2022
@AriPerkkio
Copy link
Member

Does setting esbuild.legalComments = 'inline' work?

import { defineConfig } from "vitest/config";

export default defineConfig({
  test: { ... },
  esbuild: {
    legalComments: "inline",
  },
});

Looks like esbuild@0.16.0 contained breaking change affecting this:
https://github.com/evanw/esbuild/blob/main/CHANGELOG.md#0160

  • Change the default "legal comment" behavior
    [...] You now have to opt-in to preserving them if you want this behavior.

If that works, it could be something that Vitest sets by default.

@freakzlike
Copy link
Author

Yes, it's working with legalComments: "inline". Thank you

@sheremet-va
Copy link
Member

If that works, it could be something that Vitest sets by default.

I think this should be enabled by default in Vitest 👍🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants