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

fix(coverage): report uncovered files when re-run by enter or 'a' #6848

Merged

Conversation

AriPerkkio
Copy link
Member

Description

  • Fixes bug reported on Discord:

Reproduction: https://stackblitz.com/edit/vitest-dev-vitest-mxhjvd

In this reproduction, basic2.ts is not covered by tests, but also not imported by any file in the repo (the only imported is commented-out).

Do the following:

  1. Stop the command line script
  2. Run npx vitest --coverage
  3. Observe that basic2.ts is red (uncovered)
  4. Press Enter to re-run the test
  5. Observe that basic2.ts is not in the list anymore and coverage is green.

This has broken in 1.6.0:

image

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Nov 4, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 5d8d987
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/6728dacad8a4110008b7a127
😎 Deploy Preview https://deploy-preview-6848--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to resolve value of allTestsRun here:

.finally(async () => {
// can be duplicate files if different projects are using the same file
const files = Array.from(new Set(specs.map(spec => spec.moduleId)))
const errors = this.state.getUnhandledErrors()
const coverage = await this.coverageProvider?.generateCoverage({ allTestsRun })

... based on all current filters. We could check this.state.getFiles().length === specs.length and check testNamePattern maybe..?

@sheremet-va sheremet-va merged commit 487c80a into vitest-dev:main Nov 5, 2024
17 checks passed
@AriPerkkio AriPerkkio deleted the fix/coverage-all-rerun-by-enter branch November 5, 2024 11:29
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Nov 13, 2024
##### [v2.1.5](https://github.com/vitest-dev/vitest/releases/tag/v2.1.5)

#####    🚀 Features

-   **experimental**: Expose vite on the test project as a separate field  -  by [@sheremet-va](https://github.com/sheremet-va) [<samp>(bcc59)</samp>](vitest-dev/vitest@bcc59088)

#####    🐞 Bug Fixes

-   `dangerouslyIgnoreUnhandledErrors` without base reporter  -  by [@AriPerkkio](https://github.com/AriPerkkio) in vitest-dev/vitest#6808 [<samp>(0bf0a)</samp>](vitest-dev/vitest@0bf0ab00)
-   Capture `unhandledRejection` even when base reporter is not used  -  by [@AriPerkkio](https://github.com/AriPerkkio) in vitest-dev/vitest#6812 [<samp>(8878b)</samp>](vitest-dev/vitest@8878b04d)
-   Don't change the working directory when loading workspace projects  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6811 [<samp>(f0aea)</samp>](vitest-dev/vitest@f0aeaca8)
-   Remove `sequence.concurrent` from the `RuntimeConfig` type  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6880 [<samp>(6af73)</samp>](vitest-dev/vitest@6af73d93)
-   Stop the runner before restarting, restart on workspace config change  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6859 [<samp>(b01df)</samp>](vitest-dev/vitest@b01df47d)
-   Don't rerun on Esc or Ctrl-C during watch filter  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6895 [<samp>(98f76)</samp>](vitest-dev/vitest@98f76ea7)
-   Print ssrTransform error  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6885 [<samp>(4c96c)</samp>](vitest-dev/vitest@4c96cce7)
-   Throw an error and a warning if `.poll`, `.element`, `.rejects`/`.resolves`, and `locator.*` weren't awaited  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6877 [<samp>(93b67)</samp>](vitest-dev/vitest@93b67c24)
-   **browser**:
    -   Don't process the default css styles  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6861 [<samp>(0d67f)</samp>](vitest-dev/vitest@0d67f04b)
    -   Support non US key input  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6873 [<samp>(5969d)</samp>](vitest-dev/vitest@5969d8da)
    -   Stop the browser rpc when the pool is closed  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6858 [<samp>(9a0c9)</samp>](vitest-dev/vitest@9a0c93d7)
    -   Init browsers eagerly when tests are running  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6876 [<samp>(417bd)</samp>](vitest-dev/vitest@417bdb42)
-   **coverage**:
    -   Report uncovered files when re-run by `enter` or `'a'`  -  by [@AriPerkkio](https://github.com/AriPerkkio) in vitest-dev/vitest#6848 [<samp>(487c8)</samp>](vitest-dev/vitest@487c80ae)
-   **ui**:
    -   Remove crossorigin attributes for same origin assets  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6883 [<samp>(6e793)</samp>](vitest-dev/vitest@6e793c64)
-   **vite-node**:
    -   Improve esm check to decide external  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6816 [<samp>(7e1fa)</samp>](vitest-dev/vitest@7e1faf3d)
    -   Top-level throw in module is not reported properly  -  by [@vanaigr](https://github.com/vanaigr) and [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6840 [<samp>(cf0cb)</samp>](vitest-dev/vitest@cf0cbf6a)
-   **vitest**:
    -   Use fetch() implementation from happy-dom  -  by [@capricorn86](https://github.com/capricorn86) in vitest-dev/vitest#6879 [<samp>(3c56f)</samp>](vitest-dev/vitest@3c56feb4)

#####    🏎 Performance

-   Limit workspace project concurrency to available cores  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6869 [<samp>(f4c04)</samp>](vitest-dev/vitest@f4c04ab6)

#####     [View changes on GitHub](vitest-dev/vitest@v2.1.4...v2.1.5)
renovate bot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull request Nov 13, 2024
##### [v2.1.5](https://github.com/vitest-dev/vitest/releases/tag/v2.1.5)

#####    🚀 Features

-   **experimental**: Expose vite on the test project as a separate field  -  by [@sheremet-va](https://github.com/sheremet-va) [<samp>(bcc59)</samp>](vitest-dev/vitest@bcc59088)

#####    🐞 Bug Fixes

-   `dangerouslyIgnoreUnhandledErrors` without base reporter  -  by [@AriPerkkio](https://github.com/AriPerkkio) in vitest-dev/vitest#6808 [<samp>(0bf0a)</samp>](vitest-dev/vitest@0bf0ab00)
-   Capture `unhandledRejection` even when base reporter is not used  -  by [@AriPerkkio](https://github.com/AriPerkkio) in vitest-dev/vitest#6812 [<samp>(8878b)</samp>](vitest-dev/vitest@8878b04d)
-   Don't change the working directory when loading workspace projects  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6811 [<samp>(f0aea)</samp>](vitest-dev/vitest@f0aeaca8)
-   Remove `sequence.concurrent` from the `RuntimeConfig` type  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6880 [<samp>(6af73)</samp>](vitest-dev/vitest@6af73d93)
-   Stop the runner before restarting, restart on workspace config change  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6859 [<samp>(b01df)</samp>](vitest-dev/vitest@b01df47d)
-   Don't rerun on Esc or Ctrl-C during watch filter  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6895 [<samp>(98f76)</samp>](vitest-dev/vitest@98f76ea7)
-   Print ssrTransform error  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6885 [<samp>(4c96c)</samp>](vitest-dev/vitest@4c96cce7)
-   Throw an error and a warning if `.poll`, `.element`, `.rejects`/`.resolves`, and `locator.*` weren't awaited  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6877 [<samp>(93b67)</samp>](vitest-dev/vitest@93b67c24)
-   **browser**:
    -   Don't process the default css styles  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6861 [<samp>(0d67f)</samp>](vitest-dev/vitest@0d67f04b)
    -   Support non US key input  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6873 [<samp>(5969d)</samp>](vitest-dev/vitest@5969d8da)
    -   Stop the browser rpc when the pool is closed  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6858 [<samp>(9a0c9)</samp>](vitest-dev/vitest@9a0c93d7)
    -   Init browsers eagerly when tests are running  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6876 [<samp>(417bd)</samp>](vitest-dev/vitest@417bdb42)
-   **coverage**:
    -   Report uncovered files when re-run by `enter` or `'a'`  -  by [@AriPerkkio](https://github.com/AriPerkkio) in vitest-dev/vitest#6848 [<samp>(487c8)</samp>](vitest-dev/vitest@487c80ae)
-   **ui**:
    -   Remove crossorigin attributes for same origin assets  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6883 [<samp>(6e793)</samp>](vitest-dev/vitest@6e793c64)
-   **vite-node**:
    -   Improve esm check to decide external  -  by [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6816 [<samp>(7e1fa)</samp>](vitest-dev/vitest@7e1faf3d)
    -   Top-level throw in module is not reported properly  -  by [@vanaigr](https://github.com/vanaigr) and [@hi-ogawa](https://github.com/hi-ogawa) in vitest-dev/vitest#6840 [<samp>(cf0cb)</samp>](vitest-dev/vitest@cf0cbf6a)
-   **vitest**:
    -   Use fetch() implementation from happy-dom  -  by [@capricorn86](https://github.com/capricorn86) in vitest-dev/vitest#6879 [<samp>(3c56f)</samp>](vitest-dev/vitest@3c56feb4)

#####    🏎 Performance

-   Limit workspace project concurrency to available cores  -  by [@sheremet-va](https://github.com/sheremet-va) in vitest-dev/vitest#6869 [<samp>(f4c04)</samp>](vitest-dev/vitest@f4c04ab6)

#####     [View changes on GitHub](vitest-dev/vitest@v2.1.4...v2.1.5)
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

Successfully merging this pull request may close these issues.

2 participants