Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@types/jest dependency should be changed to @jest/types #387

Closed
kompot opened this issue Jul 5, 2021 · 7 comments
Closed

@types/jest dependency should be changed to @jest/types #387

kompot opened this issue Jul 5, 2021 · 7 comments
Labels
wontfix This will not be worked on

Comments

@kompot
Copy link

kompot commented Jul 5, 2021

  • @testing-library/jest-dom version: 5.14.1
  • @types/testing-library__jest-dom version: 5.14
  • node version: 14
  • npm (or yarn) 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.

@chbdetta
Copy link

+1. Looks like @types/testing-library__jest-dom depends on pretty-format@26.6.2 and if jest is upgraded to v27, the two different version of pretty-format is causing problem possibly because pretty-format@27.0.6 exports a different value

@markusv
Copy link

markusv commented Dec 20, 2021

any progress on this? This is starting to turn into a problem for us

@gnapse
Copy link
Member

gnapse commented Dec 22, 2021

@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.

@sheremet-va
Copy link

sheremet-va commented Jan 14, 2022

Having types in dependencies is actually conflicts with Vitest: #427

@kgregory
Copy link

kgregory commented May 9, 2022

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,
	});

@rose-m
Copy link

rose-m commented May 10, 2022

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...

@nickserv
Copy link
Member

nickserv commented Sep 19, 2022

@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.

@nickserv nickserv closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2022
@nickserv nickserv added the wontfix This will not be worked on label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

8 participants