@types/testing-library__jest-dom
Stub TypeScript definitions entry for @testing-library/jest-dom, which provides its own types definitions
This package has a good security score with no known vulnerabilities.
Community Reviews
Stub package - you don't actually need this anymore
The practical issue is that having this installed can cause confusion during upgrades. If you're on jest-dom 6.x+, you should remove this package entirely. The stub exists to prevent breaks for projects that had it listed explicitly, but it adds zero value and creates an extra dependency in your tree. I've debugged type resolution issues where this package was shadowing the actual types from the main package.
From a production engineering standpoint, this package has no runtime implications since it's dev-only TypeScript definitions. However, keeping unnecessary packages increases audit surface area and dependency tree complexity. The migration path is trivial: just uninstall it and ensure you're using @testing-library/jest-dom directly.
Best for: Legacy projects that haven't migrated away from separately installed DefinitelyTyped packages.
Avoid if: You're using @testing-library/jest-dom version 6.0 or later, which includes native TypeScript definitions.
Seamless transition stub that points to first-party types
In practice, this works beautifully. If you accidentally install this package, TypeScript immediately recognizes the main library's types without any configuration headaches. The stub approach prevents type conflicts and ensures your IDE picks up the correct, up-to-date type definitions from the source package. No tsconfig changes needed, no module augmentation required.
For existing projects still using older versions, this provides a clean migration path. You can safely remove this dependency once you upgrade to @testing-library/jest-dom v6+, and everything continues working identically. The transition is completely transparent, which is exactly how package migrations should work.
Best for: Legacy projects using @testing-library/jest-dom v5 or earlier that need TypeScript support.
Avoid if: You're using @testing-library/jest-dom v6.0.0 or later, which includes types natively.
Essential stub package that's mostly invisible - which is exactly the point
The onboarding is straightforward - you just npm install it alongside @testing-library/jest-dom and the types work automatically. No configuration needed beyond your standard Jest setup. Error messages come from the actual jest-dom library, so you get helpful hints like "toBeInTheDocument is not a function" if you forget to import the matchers. The type definitions themselves are excellent, providing IntelliSense for all custom matchers like toHaveTextContent, toBeVisible, and toBeDisabled.
The only real issue is the initial confusion about why this separate package exists. The npm description helps, but newcomers sometimes wonder if they need both packages or just one. Once you understand it's just a types stub, it's completely hassle-free.
Best for: TypeScript projects using @testing-library/jest-dom that need proper type definitions for custom DOM matchers.
Avoid if: You're working in pure JavaScript projects without TypeScript where type definitions provide no value.
Sign in to write a review
Sign In