Skip to content

Use vitest#expect from the local context#12426

Merged
petebacondarwin merged 2 commits intomainfrom
vicn/expect-wrangler-4
Feb 5, 2026
Merged

Use vitest#expect from the local context#12426
petebacondarwin merged 2 commits intomainfrom
vicn/expect-wrangler-4

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Feb 5, 2026

Part of #12346

Part of a series (#12347, #12356, #12373, #12385, #12403, #12412, #12415) handling simple refactors, one package at a time to keep the review simpler.

This PR handles bucket 4 out of 4 of the wrangler package.

Code was created by OpenNext/Opus:

Wrangler Bucket 4 Migration Summary

Overview

Completed migration of the wrangler package.


ESLint Configuration

Merged all 4 bucket configurations into a single rule entry in packages/wrangler/eslint.config.mjs:

// Enforce using expect from test context for concurrency safety
{
  files: ["src/__tests__/**/*.test.ts"],
  rules: {
    "workers-sdk/no-vitest-import-expect": "error",
  },
}

Converted Files (42 trivial files)

These files were successfully migrated to use expect from the test context:

Original Trivial Files (35)

  • access.test.ts
  • ai.local.test.ts
  • api-dev.test.ts
  • api.test.ts
  • banner.test.ts
  • cfetch-utils.test.ts
  • check-fetch.test.ts
  • cli-hotkeys.test.ts
  • cli.test.ts
  • config-cache-without-cache-dir.test.ts
  • config-cache.test.ts
  • custom-build.test.ts
  • docs.test.ts
  • errors.test.ts
  • experimental-commands-api.test.ts
  • fetch-graphql-result.test.ts
  • get-host-from-url.test.ts
  • guess-worker-format.test.ts
  • hello-world.local.test.ts
  • https-options.test.ts
  • index.test.ts
  • logger.test.ts
  • logout.test.ts
  • match-tag.test.ts
  • middleware.scheduled.test.ts
  • navigator-user-agent.test.ts
  • paths.test.ts
  • process-env-populated.test.ts
  • rollback.test.ts
  • setup.test.ts
  • startup-profiling.test.ts
  • update-config-file.test.ts
  • utils-collectKeyValues.test.ts
  • version.test.ts
  • whoami.test.ts

Large Files Successfully Migrated (7)

Initially marked as complex due to size (>500 lines), but found to have no actual complex patterns:

File Lines Reason Migrated
ai.test.ts ~450 Helper functions don't use expect
cert.test.ts ~600 No helper functions at module scope
hyperdrive.test.ts ~1500 Helper functions don't use expect
mtls-certificates.test.ts ~600 No helper functions at module scope
secrets-store.test.ts ~980 Helper functions don't use expect
sentry.test.ts ~850 Helper function doesn't use expect
user.test.ts ~700 No helper functions at module scope

Complex Files (24 files with lint disabled)

These files have genuine complexity requiring eslint-disable comments:

Files with .each Patterns (9)

  • complete.test.ts - uses describe.each
  • deploy.test.ts - uses .each and custom matchers
  • find-additional-modules.test.ts - uses .each
  • init.test.ts - uses .each
  • is-local.test.ts - uses .each
  • metrics.test.ts - uses .each
  • type-generation.test.ts - uses .each
  • workflows.test.ts - uses .each
  • zones.test.ts - uses .each

Files with expect in MSW Handlers (6)

  • delete.test.ts - Helper functions use expect in MSW handlers
  • dev.test.ts - Helper function uses expect
  • pipelines.test.ts - expect inside MSW request handlers
  • provision.test.ts - Helper functions use expect in MSW handlers
  • secret.test.ts - expect inside MSW request handlers
  • tail.test.ts - Helper functions use expect

Files with Other Complex Patterns (9)

  • config-validation-pages.test.ts - complex validation logic
  • deployments.test.ts - complex deployment logic
  • friendly-validator-errors.test.ts - helper functions with expect
  • get-entry.test.ts - helper functions with expect
  • middleware.test.ts - conversion script missed some callbacks
  • output.test.ts - uses custom matchers (expect.extend)
  • package-manager.test.ts - helper functions with expect
  • vpc.test.ts - helper functions with expect
  • worker-namespace.test.ts - helper functions with expect

  • 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 5, 2026 12:56
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 5, 2026

⚠️ No Changeset found

Latest commit: 4586695

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
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 bugs or issues to report.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 5, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 4586695

Comment thread packages/wrangler/src/__tests__/init.test.ts
@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Feb 5, 2026
@petebacondarwin petebacondarwin merged commit 7e923ce into main Feb 5, 2026
36 of 39 checks passed
@petebacondarwin petebacondarwin deleted the vicn/expect-wrangler-4 branch February 5, 2026 14:11
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants