jest-dom
jest-dom copied to clipboard
`@types/jest` dependency should be changed to `@jest/types`
-
@testing-library/jest-dom
version: 5.14.1 -
@types/testing-library__jest-dom
version: 5.14 -
node
version: 14 -
npm
(oryarn
) version: yarn 1.2
Problem description:
Looks like Jest v27 types are not supported by @types/jest
and were moved to @jest/types
.
Suggested solution:
Should @types/testing-library__jest-dom
also consider upgrading this dependency?
As I can see @jest/types
do support jest < 27. Seems like a safe upgrade.
+1. Looks like @types/testing-library__jest-dom
depends on [email protected]
and if jest
is upgraded to v27, the two different version of pretty-format
is causing problem possibly because [email protected]
exports a different value
any progress on this? This is starting to turn into a problem for us
@markusv I may be able to take care of this in a week or two. But maybe you could take a shot at it? You are welcome to make a pull request contributing this change, and I'll gladly review and release when it's all good.
Having types in dependencies is actually conflicts with Vitest: https://github.com/testing-library/jest-dom/issues/427
Issue has resurfaced with breaking changes introduced with Jest 28. @types/jest
hasn't been updated yet, this causes a type error since @testing-library/jest-dom
uses @types/jest
v27:
jest.useFakeTimers({
legacyFakeTimers: true,
});
We've also recently encountered typing issues due to the conflict of Jest 28 vs. the @types/jest
things that are referenced from @testing-library/jest-dom
. Especially with the issue that the mocked
helper previously in ts-jest/utils
was moved to jest
directly. Jest states to use import { jest } from '@jest/globals';
- however, this will then break jest.mock
usage somehow (not sure why).
To work around this I'm using a jest.ts
that get's included with the following namespace augmentation:
import type { jest as globalJest } from '@jest/globals';
declare global {
namespace jest {
const mocked: typeof globalJest.mocked;
}
}
Maybe this helps someone...
@jest/types
is not a replacement for @types/jest
. @jest/types
exports some TypeScript types for internal Jest packages so external packages can import them, but it does not provide global types or config types. You would want to use it if you were writing a Jest package, not a Testing Library test.
I'm going to close this for now as I don't see a need for us to use @jest/types
now, and removing @types/jest
would be a potentially confusing breaking change. @types/jest
is still actively maintained by the community and recommended by Jest. If you need help with it, please refer to the DefinitelyTyped discussions.