How do I configure TypeScript to recognize types for `@testing-library/jest-dom` after upgrading to v6?

I ran into the exact same issue after upgrading to v6. Turns out, @testing-library/jest-dom v6 no longer ships with ambient type declarations, they switched to using ESM exports only.

That’s why TypeScript can’t pick it up globally just from “types” in tsconfig.

What worked for me was creating a setupTests.ts (or .d.ts) file and explicitly importing it:

import '@testing-library/jest-dom';

Then I referenced this file in my tsconfig.json under “include” so it’s always part of the compilation.

That way, TypeScript sees the types project-wide again without having to import them in every test.