fix(web): resolve jest-dom matcher types under pnpm via packageExtensions - #3494
Conversation
…ions ## Related issue N/A ## Summary - `@testing-library/jest-dom` never declares `vitest` as a (peer) dependency. Under pnpm's store layout, jest-dom's `declare module "vitest"` matcher-type augmentation can't resolve `vitest`, so it silently fails to merge and `tsc` loses every DOM matcher (`toBeInTheDocument`, `toHaveClass`, …) — even though they register fine at runtime. See vitest-dev/vitest#10411. - Declare the missing peer via pnpm `packageExtensions` so pnpm links `vitest` into jest-dom's scope and the augmentation resolves. This is a root-cause fix at the dependency layer — no hand-written type shim needed. - Note: `type-check` still has unrelated pre-existing errors and is not yet gated in CI; this fix only removes the jest-dom matcher category. ## Test Plan - `pnpm install --frozen-lockfile --filter web` — lockfile stays consistent. - `pnpm --filter web run type-check` — jest-dom matcher errors drop from 1589 to 0 (remaining errors are unrelated and pre-existing). - `pnpm --filter web run test` (e.g. `src/shell/WorkspacePanel.test.tsx`) — 15/15 pass under Node 22; runtime is unaffected. ## Demo N/A ## Type of change - [ ] Bug fix - [ ] Feature - [ ] UI / frontend change - [x] Refactor / chore - [ ] Docs - [ ] Test / CI - [ ] Breaking change ## Test coverage - [ ] Unit tests added / updated - [ ] Integration tests added / updated - [ ] E2E tests added / updated - [x] Manual verification completed - [x] Existing tests cover this change - [ ] Not applicable ## Coverage notes Verified by comparing `pnpm --filter web run type-check` jest-dom error counts (1589 → 0) and running the existing vitest suite (unaffected). The change is dependency-resolution config only, with no new runtime code to test. Signed-off-by: Zeyi (Rice) Fan <zeyi.f@databricks.com>
|
|
🏷️ Doc impact: This only adjusts pnpm lockfile/workspace config to re-add a vitest peer dependency for jest-dom's type augmentation — a build/tooling tweak with no user-facing surface or integration change. Auto-classified on merge. Set the label manually before merging to override. · run |
Related issue
N/A
Summary
@testing-library/jest-domnever declaresvitestas a (peer) dependency.Under pnpm's store layout, jest-dom's
declare module "vitest"matcher-typeaugmentation can't resolve
vitest, so it silently fails to merge andtscloses every DOM matcher (
toBeInTheDocument,toHaveClass, …) — even thoughthey register fine at runtime. See vitest 4.1.6+ silently breaks @testing-library/jest-dom type augmentation (toBeInTheDocument missing on Assertion) vitest-dev/vitest#10411.
packageExtensionsso pnpm linksvitestinto jest-dom's scope and the augmentation resolves. This is a root-cause fix
at the dependency layer — no hand-written type shim needed.
type-checkstill has unrelated pre-existing errors and is not yetgated in CI; this fix only removes the jest-dom matcher category.
Test Plan
pnpm install --frozen-lockfile --filter web— lockfile stays consistent.pnpm --filter web run type-check— jest-dom matcher errors drop from 1589to 0 (remaining errors are unrelated and pre-existing).
pnpm --filter web run test(e.g.src/shell/WorkspacePanel.test.tsx) —15/15 pass under Node 22; runtime is unaffected.
Demo
N/A
Type of change
Test coverage
Coverage notes
Verified by comparing
pnpm --filter web run type-checkjest-dom error counts(1589 → 0) and running the existing vitest suite (unaffected). The change is
dependency-resolution config only, with no new runtime code to test.