Skip to content

Use vitest#expect from the local context#12412

Merged
vicb merged 1 commit intomainfrom
vicb/expect-wrangler-2
Feb 4, 2026
Merged

Use vitest#expect from the local context#12412
vicb merged 1 commit intomainfrom
vicb/expect-wrangler-2

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Feb 4, 2026

Part of #12346

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

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

Code was created by OpenNext/Opus:

Wrangler Bucket 2 Migration Summary

Overview

Bucket 2 of the wrangler migration has been completed. This covered 31 test files across 4 directories.

Results

Directory Total Files Trivial (converted) Complex (eslint-disable)
r2/ 10 5 5
containers/ 9 2 7
cloudchamber/ 10 1 9
vectorize/ 2 0 2
Total 31 8 23

File Details

R2 Files (10 files)

File Status Reason
r2/local-uploads.test.ts eslint-disable expect in MSW handlers
r2/bucket.test.ts eslint-disable expect in MSW handlers + helper functions
r2/object.test.ts eslint-disable expect in MSW handlers
r2/bulk.test.ts eslint-disable expect in MSW handlers
r2/sql.test.ts eslint-disable expect in MSW handlers
r2/notification.test.ts converted 3 tests, trivial
r2/pipe.test.ts converted 2 tests, trivial
r2/local.test.ts converted 4 tests, trivial
r2/help.test.ts converted 2 tests, trivial
r2/errors.test.ts converted 1 test, trivial

Containers Files (9 files)

File Status Reason
containers/list.test.ts eslint-disable expect in MSW handlers
containers/registries.test.ts eslint-disable expect in MSW handlers + helper functions
containers/delete.test.ts eslint-disable expect in MSW handlers + helper functions
containers/deploy.test.ts eslint-disable Large file (30+ tests)
containers/images.test.ts eslint-disable expect in MSW handlers
containers/info.test.ts eslint-disable expect in MSW handlers
containers/config.test.ts eslint-disable 30+ tests
containers/push.test.ts converted 7 tests, trivial
containers/ssh.test.ts converted 4 tests, trivial

Cloudchamber Files (10 files)

File Status Reason
cloudchamber/list.test.ts eslint-disable expect in MSW handlers
cloudchamber/images.test.ts eslint-disable expect in MSW handlers
cloudchamber/modify.test.ts eslint-disable expect in MSW handlers + helper functions
cloudchamber/delete.test.ts eslint-disable expect in MSW handlers
cloudchamber/curl.test.ts eslint-disable expect in MSW handlers
cloudchamber/create.test.ts eslint-disable expect in MSW handlers + helper functions
cloudchamber/apply.test.ts eslint-disable expect in MSW handlers (mockCreateApplication, mockModifyApplication)
cloudchamber/limits.test.ts eslint-disable vi.mock patterns with expect in tests
cloudchamber/build.test.ts eslint-disable vi.mock patterns
cloudchamber/common.test.ts converted 1 test, trivial

Vectorize Files (2 files)

File Status Reason
vectorize/vectorize.test.ts eslint-disable Large file (1500+ lines), expect in MSW handlers
vectorize/vectorize.upsert.test.ts eslint-disable expect in MSW handlers

ESLint Config Entry

The following entry was already added to packages/wrangler/eslint.config.mjs (lines 47-55):

{
  files: ["src/__tests__/{r2,cloudchamber,containers,vectorize}/**/*.test.ts"],
  rules: {
    "workers-sdk/no-vitest-import-expect": "error",
  },
},

Verification

  • Lint check: pnpm --filter wrangler check:lint - PASSED
  • No errors or warnings

Notes

  1. High complexity ratio: Bucket 2 has a high ratio of complex files (23/31 = 74%) compared to bucket 1 (12/39 = 31%). This is primarily due to:

    • Heavy use of MSW (Mock Service Worker) for API mocking
    • Many helper functions that use expect inside MSW handlers
    • Large test files with many tests
  2. Common pattern: Most complex files use a pattern where expect is called inside MSW request handlers to validate request bodies/parameters before returning mock responses.

  3. eslint-disable format: Used block comments for the disable/enable pattern:

    /* eslint-disable workers-sdk/no-vitest-import-expect -- reason */
    import { describe, expect, it } from "vitest";
    /* eslint-enable workers-sdk/no-vitest-import-expect */

Next Steps

Remaining buckets for wrangler migration:

Bucket Directories Files Status
3 versions/, autoconfig/, api/, deploy/, dev/, config/, utils/, core/, metrics/ 40 Pending
4 Root-level files (src/__tests__/*.test.ts) 66 Pending

  • 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 a user facing change

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 4, 2026 15:09
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 4, 2026

⚠️ No Changeset found

Latest commit: a7733e8

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

View in Devin Review to see 4 additional flags.

Open in Devin Review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 4, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: a7733e8

Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

do we need separate buckets of config?

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Feb 4, 2026
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Feb 4, 2026

do we need separate buckets of config?

We don't and I wouldn't have written this in this way...
But it's going away once all the buckets are tackled anyway

@vicb vicb merged commit f33d86b into main Feb 4, 2026
52 of 61 checks passed
@vicb vicb deleted the vicb/expect-wrangler-2 branch February 4, 2026 17:31
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 4, 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