Skip to content

[vitest-pool-workers] Support @voidzero-dev/vite-plus-test as vitest alternative#13075

Merged
penalosa merged 3 commits intomainfrom
penalosa/vitest-13001
Mar 30, 2026
Merged

[vitest-pool-workers] Support @voidzero-dev/vite-plus-test as vitest alternative#13075
penalosa merged 3 commits intomainfrom
penalosa/vitest-13001

Conversation

@penalosa
Copy link
Copy Markdown
Contributor

@penalosa penalosa commented Mar 26, 2026

Fixes #13001.

When users run tests via Vite+ (@voidzero-dev/vite-plus-test) with the recommended pnpm overrides, two things break:

  1. Version check rejects 0.1.14assertCompatibleVitestVersion compares the distribution's own version (0.1.14) against our peerDependencies.vitest constraint (^4.1.0). Fix: read the bundledVersions.vitest field from the distribution's package.json to get the real upstream version (e.g. 4.1.1).

  2. Disallowed operation called within global scope — vite-plus-test eagerly initialises @sinonjs/fake-timers during module loading, which calls setTimeout. Our monkeypatchedSetTimeout guard blocks this because the call originates from @voidzero-dev/vite-plus-test rather than vitest. Fix: add @voidzero-dev/vite-plus-test to the fromVitest allowlist regex.

Setup required by users

Per vite-plus's bundling docs, users must configure pnpm overrides to alias vitest to @voidzero-dev/vite-plus-test:

{
  "pnpm": {
    "overrides": {
      "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
      "@vitest/runner": "npm:@voidzero-dev/vite-plus-test@0.1.14",
      "@vitest/snapshot": "npm:@voidzero-dev/vite-plus-test@0.1.14"
    }
  }
}

Verified end-to-end in an isolated reproduction project outside the monorepo.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: verified in an isolated reproduction project outside the monorepo with vite-plus@0.1.14 + pnpm overrides. Cannot add a CI fixture because vite-plus requires the recommended pnpm overrides setup, which would mess up the rest of workers-sdk
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: follows vite-plus's existing setup guide

Open with Devin

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: 2ec74bd

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

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-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

✅ All changesets look good

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

Adds support for @voidzero-dev/vite-plus-test as an alternative vitest distribution by extracting the upstream vitest version from @vitest/* deps and allowlisting the package in the setTimeout monkeypatch.

One minor robustness concern:

  1. getUpstreamVitestVersion returns the raw dependency version string from peerDependencies/devDependencies. Today vite-plus-test@0.1.14 pins these to exact versions (e.g. "@vitest/ui": "4.1.1"), but if a future release uses a range like ^4.1.1, semverSatisfies would receive an invalid version string, silently return false, and emit a spurious compatibility warning. A defensive semver.coerce() call (or a comment documenting the assumption) would make this more resilient.

Comment thread packages/vitest-pool-workers/src/pool/index.ts Outdated
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Mar 26, 2026

Review posted successfully on PR #13075. I flagged one minor robustness concern: getUpstreamVitestVersion returns raw dependency version strings that could contain range prefixes (e.g., ^4.1.1) in future releases, which would cause semverSatisfies to silently return false and emit a spurious compatibility warning. I included a concrete suggestion to strip range prefixes defensively.

github run

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 26, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13075

@cloudflare/workers-editor-shared

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

wrangler

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

commit: 2ec74bd

@penalosa penalosa force-pushed the penalosa/vitest-13001 branch 2 times, most recently from 3ac4c1b to 18553d6 Compare March 27, 2026 00:45
…alternative

- Extract real upstream vitest version from @vitest/* peer/devDependencies
  in the distribution's package.json instead of using its own version (0.x)
- Add vite-plus-test to the setTimeout monkeypatch allowlist so its eager
  fake-timer initialisation isn't blocked by the global-scope guard
@penalosa penalosa force-pushed the penalosa/vitest-13001 branch from 18553d6 to c86763f Compare March 27, 2026 00:46
Support '@voidzero-dev/vite-plus-test' as an alternative to 'vitest'. Fix version compatibility checks and monkeypatch behavior for better integration.
Comment thread packages/vitest-pool-workers/src/pool/index.ts Outdated
@penalosa penalosa marked this pull request as ready for review March 27, 2026 00:53
@penalosa penalosa requested a review from a team as a code owner March 27, 2026 00:53
@penalosa penalosa requested a review from ascorbic March 27, 2026 00:53
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@workers-devprod
Copy link
Copy Markdown
Contributor

workers-devprod commented Mar 27, 2026

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@penalosa penalosa force-pushed the penalosa/vitest-13001 branch from 7009987 to 2ec74bd Compare March 27, 2026 01:07
Comment thread packages/vitest-pool-workers/src/pool/index.ts
@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Mar 30, 2026
@penalosa penalosa merged commit b8df076 into main Mar 30, 2026
54 of 55 checks passed
@penalosa penalosa deleted the penalosa/vitest-13001 branch March 30, 2026 12:52
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Mar 30, 2026
NuroDev pushed a commit that referenced this pull request Mar 30, 2026
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.

Support vite plus for @cloudflare/vitest-pool-workers

3 participants