AFFiNE icon indicating copy to clipboard operation
AFFiNE copied to clipboard

chore: upgrade vitest from v3 to v4

Open fengmk2 opened this issue 1 month ago • 2 comments

  • Update vitest and related packages to 4.0.15
  • Migrate workspace config to use projects array (defineWorkspace -> defineConfig with test.projects)
  • Remove deprecated coverage.all option
  • Migrate poolOptions.forks.singleFork to maxWorkers/isolate options
  • Fix incorrect import of afterEach from node:test in utils.spec.ts

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated Vitest testing framework dependencies to version 4.0.15 across the project.
    • Updated Vitest configuration to use new API patterns and worker/isolation settings.
    • Cleaned up test configuration imports and settings for consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

fengmk2 avatar Dec 04 '25 01:12 fengmk2

[!IMPORTANT]

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR upgrades Vitest from v3.1.3 to v4.0.15, updates test configuration files to align with Vitest 4's new APIs (replacing poolOptions with maxWorkers/isolate settings, switching from defineWorkspace to defineConfig), removes redundant coverage settings, and consolidates imports.

Changes

Cohort / File(s) Summary
Vitest dependency upgrade
package.json
Updates @vitest/browser, @vitest/coverage-istanbul, @vitest/ui, and vitest from 3.1.3 to 4.0.15 in devDependencies.
Vitest configuration migration
vitest.config.ts, vitest.workspace.ts, packages/frontend/apps/electron/vitest.config.ts
Vitest 4.0 API changes: replaces poolOptions.forks.singleFork with maxWorkers/isolate settings; switches workspace config from defineWorkspace() to defineConfig() with nested test.projects structure; removes explicit coverage.all: false setting.
Test file import consolidation
packages/frontend/core/src/modules/navigation/__tests__/utils.spec.ts
Merges separate node:test and vitest imports into a single vitest import statement.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Vitest 4.0 configuration API changes: The poolOptions to maxWorkers/isolate migration and defineWorkspace to defineConfig refactor require verification of behavioral equivalence and confirmation that test execution remains correct.
  • Coverage configuration removal: Verify that removal of coverage.all: false doesn't alter intended coverage reporting behavior under the new version.
  • Test file consolidation: Confirm that the import consolidation doesn't introduce unintended runtime changes (although unlikely for this case).

Poem

🐰 From version three to four we leap, New configs help the tests run deep, With workers pooling all our might, And workspaces configured just right, Vitest hops toward the light! 🐇✨

Pre-merge checks and finishing touches

✅ 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 accurately summarizes the main change: upgrading Vitest from v3 to v4, which is reflected across all modified files including dependency bumps, config migrations, and API updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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[bot] avatar Dec 04 '25 01:12 coderabbitai[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 47.78%. Comparing base (bcc892c) to head (9537b0a).

Additional details and impacted files
@@            Coverage Diff             @@
##           canary   #14045      +/-   ##
==========================================
- Coverage   57.15%   47.78%   -9.38%     
==========================================
  Files        2757     2184     -573     
  Lines      137728   115975   -21753     
  Branches    21155    15466    -5689     
==========================================
- Hits        78724    55420   -23304     
- Misses      56776    59932    +3156     
+ Partials     2228      623    -1605     
Flag Coverage Δ
server-test 77.29% <ø> (-1.18%) :arrow_down:
unittest 14.33% <ø> (-17.66%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 04 '25 02:12 codecov[bot]