fix(headless): register jest-dom matcher types for vitest 4#8821
Conversation
@testing-library/jest-dom/vitest registers its matcher types via a triple-slash reference that does not take effect when re-exported through this package's test setup, leaving toBeInTheDocument/toHaveAttribute and friends untyped across all test files (340 tsc errors, invisible in CI). Declare the vitest module augmentation explicitly, and run tsc as part of the package's lint task so the test files are type-checked in CI.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: cbad8aa The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Repository UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR fixes TypeScript type declarations for jest-dom matchers in Vitest by replacing an indirect import with explicit module augmentation. A ChangesJest-DOM matcher types and TypeCheck validation
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
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. Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Problem
All test files in
@clerk/headlesshad jest-dom matchers (toBeInTheDocument,toHaveAttribute, …) showing as TypeScript errors — 340tscerrors across 11 files:Root cause
Vitest 4's
Assertioninterface is only augmentable from a file that is a proper module.@testing-library/jest-dom/vitest(the latest, v6.9.1) registers its matcher types via a triple-slash/// <reference>to an internal declaration file:That referenced augmentation does not take effect when pulled in through this package's
src/test-utils/jest-dom.d.tsre-export, so the matchers were never attached to the typeexpect()returns. Runtime was unaffected (matchers are registered viaexpect.extendinvitest.setup.ts), which is why tests passed and the errors were editor-only.Why CI never caught it
The package had no typecheck step —
build(vite-plugin-dts excludes*.test.tsx),lint(eslint), andtest(vitest, runtime only) never rantscover test files.Fix
vitestmodule augmentation explicitly injest-dom.d.ts(the manual setup jest-dom documents), matching the pattern the siblingvitest-axe.d.tsalready uses.tsc --noEmitinto the package'slintscript so test files are type-checked by the existingturbo lintCI job — scoped to@clerk/headless, no global turbo/CI changes.Verification
tsc --noEmit: 340 errors → 0vitest run: 402 passed, 1 skipped (unchanged)turbo lint --filter @clerk/headless: passes (0 errors; 11 pre-existing warnings untouched)Summary by CodeRabbit
Tests
Chores