Skip to content

Use vitest#expect from the local context#12452

Open
vicb wants to merge 3 commits intomainfrom
vicb/vite-expect-2
Open

Use vitest#expect from the local context#12452
vicb wants to merge 3 commits intomainfrom
vicb/vite-expect-2

Conversation

@vicb
Copy link
Contributor

@vicb vicb commented Feb 6, 2026

Part of #12346

This PR handles bucket 2 out of 2 of the vite package to keep its size reasonable.
Only trivial cases are handled.
More complex cases will be handled as a follow-up and only disable the ESLint rule for now.

The code was created by OpenNext/Opus:

vite-plugin-cloudflare — Bucket 2 (Final) Summary

Scope

Bucket 2: playground/[n-z]* + src/__tests__/51 files importing expect from vitest

This completes the vite-plugin-cloudflare migration. All test files in the package are now covered by the no-vitest-import-expect rule.

ESLint Configuration (eslint.config.mjs)

Changes

Merged the bucket 1 pattern (playground/[a-m]*/**/__tests__/**/*.ts) with the new bucket into a single config block:

The e2e config block remains separate (it has its own languageOptions and standalone plugins registration since e2e files are excluded from the shared config).

Migration Results

Category Files Details
Trivial playground (converted) 40 All playground/[n-z]* spec + base-tests files
Trivial src (converted) 8 7 straightforward + 1 with expect passed via closure (resolve-plugin-config)
Complex (lint disable) 2 websockets (helper fn) + get-validated-wrangler-config-path (.forEach)
No changes needed 7 Files that don't import expect from vitest
Total files in scope 57

Converted to complex, then further fixed (1 file)

playground/websockets/__tests__/websockets.spec.ts — initially marked complex due to expect used in the module-scope openWebSocket() helper. Resolved by adding an expect: ExpectStatic parameter to openWebSocket() and passing it from each test's context. No eslint-disable needed.

Verification

  • Lint: pnpm --filter @cloudflare/vite-plugin check:lint — passes (0 warnings)
  • Types: pnpm --filter @cloudflare/vite-plugin check:type — passes
  • Unit tests: pnpm --filter @cloudflare/vite-plugin test:ci — 10 files, 66 tests, all passing

  • 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: not user facing

A picture of a cute animal (not mandatory, but encouraged)


Open with Devin

@vicb vicb requested a review from a team as a code owner February 6, 2026 14:54
@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

⚠️ No Changeset found

Latest commit: 9e1a6c4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

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

Copy link
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 5 additional findings.

Open in Devin Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 6, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 9e1a6c4

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

2 participants