Skip to content

[vitest-plugin] Fix V8 coverage teardown with Vitest 5.0.4 - #16248

Merged
edmundhung merged 3 commits into
mainfrom
mjp/fix-vitest-v8-coverage
Oct 15, 2026
Merged

edmundhung merged 3 commits into
mainfrom
mjp/fix-vitest-v8-coverage

Conversation

@mattjohnsonpint

@mattjohnsonpint mattjohnsonpint commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Vitest 5.0.4 introduces a __vitest_stopV8Coverage command for isolated test teardown. The Workers runner does not recognize it and instead asserts that the command is __vitest_writeCoverageFile, causing V8 coverage runs to fail.

Handle the new command using the existing inspector-session cleanup. Extend the V8 regression to verify coverage across sequential isolated test files, and include a patch changeset.

Both coverage fixtures temporarily set fsModuleCache: false to test this fix independently of the filesystem-cache incompatibility. Remove these overrides once PR #16163 is merged.

Validation:

  • V8 and Istanbul coverage tests passed with Vitest 5.0.3 and 5.0.4.
  • Build, typechecking, type-aware lint, and formatting passed.

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: this restores existing V8 coverage behavior without changing the public API.

Devin Review

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25f015d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vitest-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Oct 13, 2026
@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team October 13, 2026 18:57
@workers-devprod

workers-devprod commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

devin-ai-integration[bot]

This comment was marked as resolved.

@ask-bonk

ask-bonk Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

@pkg-pr-new

pkg-pr-new Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@16248

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@16248

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16248

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@16248

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16248

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@16248

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@16248

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@16248

miniflare

npm i https://pkg.pr.new/miniflare@16248

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@16248

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@16248

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16248

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@16248

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@16248

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16248

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@16248

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@16248

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@16248

wrangler

npm i https://pkg.pr.new/wrangler@16248

commit: 25f015d

Handle __vitest_stopV8Coverage by stopping and disconnecting the existing inspector session instead of falling through to the coverage-file assertion.

Extend the default-provider regression to verify coverage across sequential isolated test files, improve failure diagnostics, and add a patch changeset.
Set fsModuleCache to false in both coverage fixtures so Vitest 5.0.4 can exercise coverage independently of the filesystem-cache incompatibility.

This workaround is temporary until PR #16163 is merged; remove the overrides once the cache fix is available.

Validation: both coverage tests passed with Vitest 5.0.4 in the fixture processes; type-aware lint and formatting passed.

@edmundhung edmundhung left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you 🫶

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Oct 14, 2026
@mattjohnsonpint
mattjohnsonpint enabled auto-merge (squash) October 14, 2026 16:09
@edmundhung
edmundhung disabled auto-merge October 15, 2026 12:09
@edmundhung
edmundhung merged commit ad01099 into main Oct 15, 2026
94 checks passed
@edmundhung
edmundhung deleted the mjp/fix-vitest-v8-coverage branch October 15, 2026 12:10
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Oct 15, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 19, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `@cloudflare/vitest-plugin` | 1.4.2 | 1.4.4 | patch |

## Release Notes

<details>
<summary><b>@<!---->cloudflare/vitest-plugin</b> (1.4.2 → 1.4.4) — 2
releases</summary>

<details>
<summary><b>1.4.4</b></summary>

### Patch Changes

- Updated dependencies
[[`e1d1b77`](cloudflare/workers-sdk@e1d1b77),
[`e13d5cc`](cloudflare/workers-sdk@e13d5cc),
[`42c6912`](cloudflare/workers-sdk@42c6912),
[`4a5377f`](cloudflare/workers-sdk@4a5377f)]:
  - miniflare@5.20261012.1-beta
  - wrangler@4.151.1

</details>

<details>
<summary><b>1.4.3</b></summary>

### Patch Changes

- [#16248](cloudflare/workers-sdk#16248)
[`ad01099`](cloudflare/workers-sdk@ad01099)
Thanks [@<!---->mattjohnsonpint](https://github.com/mattjohnsonpint)! -
Fix V8 coverage failing with Vitest 5.0.4

Tests using V8 coverage with Vitest 5.0.4 no longer fail with an
assertion error during teardown.

- [#16163](cloudflare/workers-sdk#16163)
[`5f12934`](cloudflare/workers-sdk@5f12934)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Fix
Workers tests failing with Vitest's filesystem module cache

This supports Vitest 4.1's `test.experimental.fsModuleCache` and Vitest
5's `test.fsModuleCache`.

</details>

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants