Skip to content

chore(deps-dev): bump vitest from 2 to 4 and migrate config - #3850

Merged
cixzhang merged 3 commits into
mainfrom
chore/vitest4
Jul 11, 2026
Merged

cixzhang merged 3 commits into
mainfrom
chore/vitest4

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Supersedes #3836 (the Dependabot vitest bump), which failed CI on lint, test, and build.

What

Bumps vitest (and @vitest/coverage-v8) from 2.x to 4.1.9 across the root and docsite, and migrates the config and tests for Vitest 4's breaking changes.

Why the Dependabot PR failed

Vitest 4 is a two-major bump with several breaking changes the raw version bump didn't account for:

  1. vitest.workspace.ts was removed in favor of inline test.projects. Without migrating, the ui/node project partitioning was ignored, so the node project's globs pulled in apps/docsite tests (which need generated files) and failed to resolve @astryxdesign/core.
  2. poolOptions was removed — its options are now top-level (execArgv).
  3. Mocks called with new now construct — an arrow-function vi.fn() used as a ResizeObserver constructor throws <anonymous> is not a constructor.
  4. Suite functions can no longer be called inside it() — ESLint's RuleTester.run() registers its own describe/it, so wrapping it in it() now errors. These tests were effectively vacuous before (the inner cases never ran).

Changes

  • Migrate vitest.workspace.ts → test.projects in vitest.config.ts, preserving the ui/node split; move poolOptions.forks.execArgv to top-level execArgv.
  • Fix the sharedResizeObserver mock to use a function expression.
  • Fix the four ESLint RuleTester tests to call ruleTester.run(...) at the top level, and add the now-required suggestions assertions the skipped cases never exercised.
  • no-raw-paragraph: dedupe a double-report of a destructured element-type default (the Property visitor already covers what AssignmentPattern was also flagging) — surfaced only once the RuleTester cases actually run.
  • Add "node" to the tsconfig types array so node:fs types resolve. The new dependency graph otherwise left them unresolved, collapsing readdirSync results to any and producing spurious type-aware lint errors (promise-function-async, no-unnecessary-type-assertion) on unrelated core files.

Verification

Locally: pnpm build, the storybook + core typechecks, the full pnpm test suite (332 files, 6232 tests), and CI-mode lint all pass.

Bump vitest (and @vitest/coverage-v8) to 4.1.9 across the root and docsite,
and migrate the config/tests for Vitest 4's breaking changes:

- Replace the removed `vitest.workspace.ts` with inline `test.projects` in
  vitest.config.ts, preserving the ui/node partitioning.
- Move the removed `poolOptions.forks.execArgv` to the top-level `execArgv`.
- Fix the sharedResizeObserver mock: Vitest 4 constructs mocks called with
  `new`, so the ResizeObserver mock must use a function expression, not an
  arrow.
- Fix the ESLint RuleTester tests (boolean-prop-naming, copyright-header,
  no-hardcoded-anchor, no-raw-paragraph): RuleTester registers its own
  describe/it internally, which Vitest 4 forbids inside another `it()`. Call
  `ruleTester.run(...)` at the top level, and add the now-required
  `suggestions` assertions that the previously-skipped cases never exercised.
- no-raw-paragraph: dedupe the double-report of a destructured element-type
  default (the Property visitor already covers what the AssignmentPattern
  visitor was also flagging) — surfaced once the RuleTester cases actually run.
- Add "node" to the tsconfig `types` so `node:fs` types resolve; the new dep
  graph otherwise left them unresolved, turning `readdirSync` results into
  `any` and producing spurious type-aware lint errors on unrelated core files.

Verified locally: pnpm build, storybook/core typechecks, the full test suite,
and CI-mode lint all pass.
@cixzhang
cixzhang requested a review from imdreamrunner as a code owner July 11, 2026 22:37
@vercel

vercel Bot commented Jul 11, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 11, 2026 11:37pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 11, 2026

@thedjpetersen thedjpetersen 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.

Approved.

Vitest 4's stricter vi.fn() return typing made the mock's inferred shape
incompatible with the global ResizeObserver constructor under tsc, breaking
the core typecheck (tests included). Cast the mock to typeof ResizeObserver.
@github-actions

github-actions Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.6KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

…est 4

The build-theme.* suites need a compiled @astryxdesign/core and build it
on demand from their beforeAll via a filesystem-locked helper. Under Vitest
4's reworked pool scheduling, a worker could fall through to the fallback
build path and run core's `rimraf dist && build` while another suite was
reading dist, failing with "Could not resolve dist/index.js".

Build core once in a `node`-project globalSetup, before any worker forks, so
every suite's beforeAll short-circuits on the existing dist and no two builds
ever run concurrently.
github-actions Bot added a commit that referenced this pull request Jul 11, 2026
@cixzhang
cixzhang merged commit 5493055 into main Jul 11, 2026
17 checks passed
cixzhang pushed a commit that referenced this pull request Jul 12, 2026
With vitest 2->4 (#3850) and the single-vite-7 catalog (#3847) landed,
the remaining vite 8 step is a version alignment:

- catalog: vite ^7.3.6 -> ^8.1.3 (8.1.4 is still inside the 7-day
  minimumReleaseAge window)
- root @vitejs/plugin-react ^4.3.0 -> ^5.2.0: 4.x peers stop at vite 7,
  5.2.0 supports vite ^4-^8. plugin-react 6 is vite-8-only and adds a
  react-compiler peer, so it is left for a follow-up.
- the standalone example apps and the vibe-tests preview app pin
  vite ^8.1.3 + plugin-react ^5.2.0 by hand — they live outside the
  workspace, so the catalog bump does not reach them
- packages/build keeps "vite": "catalog:" as its peer (storybook and
  sandbox still depend on it in-workspace; a floating peer range is how
  the two-vite split of 2e64c59 happened), which narrows its published
  peer to ^8.1.3 on the next release

Verified: exactly one vite (8.1.3) in the lockfile; storybook tsc and a
full storybook build on rolldown; root (6247 tests) and docsite (217)
suites green; packages/build builds. vibe-tests preview:build fails
identically on main with vite 7 (missing tailwind.css import and a
directory alias) — pre-existing, not a vite 8 regression.
@github-actions
github-actions Bot deleted the chore/vitest4 branch July 12, 2026 06:57

This branch was successfully deployed

1 active deployment
Preview — ef02ea18 Deployed Jul 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants