question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`@types/jest` dependency should be changed to `@jest/types`

See original GitHub issue
  • @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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rose-mcommented, 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…

1reaction
chbdettacommented, Jul 26, 2021

+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

Read more comments on GitHub >

github_iconTop Results From Across the Web

types/jest
Start using @types/jest in your project by running `npm i @types/jest`. ... Dependencies: @types/expect, @types/pretty-format ...
Read more >
Will there be a @types/jest version 27?
Yes, DefinitelyTyped is not related to Jest. Actually DefinitelyTyped is maintained by folks of the TypeScript team at Microsoft and of course ...
Read more >
Configuring Jest
The directory where Jest should store its cached dependency ... A list of reporter names that Jest uses when writing coverage reports.
Read more >
@jest/types | Yarn - Package Manager
If you are looking for types of Jest globals, you can import them from @jest/globals package: import {describe, expect, it} from '@jest/globals'; describe('my ......
Read more >
Testing constructs - AWS Cloud Development Kit ...
There are two categories of tests that you can write for AWS CDK apps. ... cdk init --language=typescript npm install --save-dev jest @types/jest....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found