Skip to content

Vitest v4 - #1867

Merged
dangeredwolf merged 7 commits into
mainfrom
vitest4
Mar 22, 2026
Merged

dangeredwolf merged 7 commits into
mainfrom
vitest4

Conversation

@dangeredwolf

@dangeredwolf dangeredwolf commented Mar 22, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Chores
    • Updated development tooling versions for better testing and code quality
    • Modified error reporting initialization
    • Reorganized test configuration setup

@dangeredwolf dangeredwolf self-assigned this Mar 22, 2026
@coderabbitai

coderabbitai Bot commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR updates development dependencies including vitest to v4.1.0 and the Cloudflare vitest pool to v0.13.0, refactors Sentry RewriteFrames to load dynamically instead of statically, and restructures vitest configuration to use a new cloudflareTest plugin with automatic wrangler config path resolution.

Changes

Cohort / File(s) Summary
Dev Dependencies
package.json
Bumped vitest to ^4.1.0, @cloudflare/vitest-pool-workers to ^0.13.0, and downgraded @typescript-eslint/* tools to ^8.57.0.
Sentry Integration
src/worker.ts
Replaced static import of RewriteFrames with dynamic import that executes when SENTRY_DSN is truthy, deferring module load until initialization time.
Vitest Configuration
vitest.config.mts
Introduced cloudflareTest plugin with conditional wrangler config path resolution (prefers wrangler.toml, falls back to wrangler.example.toml), disabled remote bindings, and configured Twitter proxy mock binding. Removed prior test.pool and test.poolOptions configuration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~18 minutes

Poem

🐰 Hops of joy for versions new,
Vitest leaps from three to four,
Dynamic imports, wrangler too,
Config flows much cleaner than before!
Tests run swift on Cloudflare's shore! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Vitest v4' directly reflects the main change: upgrading Vitest from v3 to v4 across the codebase, which required config restructuring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vitest4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
vitest.config.ts (1)

15-17: Make the fallback TwitterProxy mock more defensive.

At Line 16, returning {} is brittle if any test path accidentally consumes this fallback. Returning { data: {} } with JSON content-type gives a safer default.

♻️ Suggested refinement
         serviceBindings: {
-          TwitterProxy: async () => new Response('{}')
+          TwitterProxy: async () =>
+            new Response(JSON.stringify({ data: {} }), {
+              headers: { 'content-type': 'application/json' }
+            })
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@vitest.config.ts` around lines 15 - 17, The fallback mock for
serviceBindings.TwitterProxy should return a defensive JSON response rather than
bare {} — update the async factory for TwitterProxy so it returns a Response
whose body is '{"data":{}}' and includes a Content-Type: application/json header
(i.e., change the Response construction inside serviceBindings -> TwitterProxy
to serialize { data: {} } and set the appropriate header).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@vitest.config.ts`:
- Line 7: Replace the hardcoded wrangler configPath by computing a path variable
that uses './wrangler.toml' if present and falls back to
'./wrangler.example.toml' when the local file is missing; update the vitest
config's wrangler property (the wrangler: { configPath: ... } entry) to
reference that computed path, using a simple file-existence check (e.g.,
fs.existsSync or equivalent) before assigning to configPath so CI/fresh clones
use the example file.

---

Nitpick comments:
In `@vitest.config.ts`:
- Around line 15-17: The fallback mock for serviceBindings.TwitterProxy should
return a defensive JSON response rather than bare {} — update the async factory
for TwitterProxy so it returns a Response whose body is '{"data":{}}' and
includes a Content-Type: application/json header (i.e., change the Response
construction inside serviceBindings -> TwitterProxy to serialize { data: {} }
and set the appropriate header).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3f62c8e3-dea9-4c53-8864-be12ffa7a248

📥 Commits

Reviewing files that changed from the base of the PR and between 848b558 and 6e95c0a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • package.json
  • src/worker.ts
  • vitest.config.ts

Comment thread vitest.config.ts Resolved
@dangeredwolf
dangeredwolf merged commit 3e7e4a8 into main Mar 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant