Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/headless-jest-dom-matcher-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 3 additions & 2 deletions packages/headless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@
"scripts": {
"build": "rm -rf dist && vite build",
"dev": "vite build --watch",
"lint": "eslint src",
"test": "vitest run"
"lint": "eslint src && pnpm typecheck",
"test": "vitest run",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@floating-ui/react": "catalog:repo"
Expand Down
17 changes: 16 additions & 1 deletion packages/headless/src/test-utils/jest-dom.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
import '@testing-library/jest-dom/vitest';
import 'vitest';
import './vitest-axe';

import type { TestingLibraryMatchers } from '@testing-library/jest-dom/matchers';

// `@testing-library/jest-dom/vitest` registers its matcher types via a
// triple-slash `/// <reference>` to an internal declaration file, which does not
// reliably apply when re-exported through this package's test setup. Declare the
// `vitest` module augmentation explicitly so `expect(...).toBeInTheDocument()` and
// friends are typed. `import 'vitest'` keeps this file a module augmentation
// rather than an ambient module declaration that would shadow vitest's own types.
declare module 'vitest' {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface Assertion<T = any> extends TestingLibraryMatchers<any, T> {}
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface AsymmetricMatchersContaining extends TestingLibraryMatchers<any, any> {}
}
Loading