Skip to content

FAQ: migrate to jest 27/testing-library >=11 #16949

Closed
@Hotell

Description

@Hotell

Main purpose of this issue is to track issues related to jest/typescript/testing tools used.

Take this as main go to document, for person/team which is gonna tackle migration to jest26/latest testing library/typescript 4


Current state (August 2021):

Versions used within our monorepo:

  • Jest 24
  • TS 4.1
  • testing-library/react: 10.4.9.

I wanna bump testing-library/react to v11

Now unblocked since we're using typescript 4.1 (>= 3.8), but not scheduled

Previous details:

@testing-library/react v11 has as direct dependency on @testing-library/dom version >=7.22.4:

  • @testing-library/dom , starting version 7.22.4, has direct dependency on pretty-format 26.x
    • pretty-format 26.x:
      • uses TS 3.8 type syntax (thus making TSC explode as it parses unknown language syntax)
      • has direct dependency on @jest/types 26.x
      • @jest/types 26.x
        • uses TS 3.8 lang features as well (import type {} ...)

💡 NOTE:
As a consequence of @testing-library/react using dangerous ^ for its dom dependency, we need to explicitly anchor it by ourselves via yarn resolution field to version -> @testing-library/dom": "7.22.3"

✅ done! I wanna bump typescript to 3.9.x/4.1.x

this is done, expand for old notes Upgrades to 3.8 and 3.9 were blocked by major bugs, which are fixed as of 4.0.

More details of what will be involved in the typescript 4 upgrade are in #16101. Unfinished draft PR at #16449.

Why:

I wanna bump jest to 27

Now unblocked since we're using typescript 4.1 (>= 3.8), but not scheduled.

Tracked by #18442

Why:

Jest 26 uses export type which requires TS 3.8+.

On initial investigation, Jest 25 doesn't have these typing issues (at least with skipLibCheck). Though when upgrading related dependencies you have to be careful to avoid installing anything that pulls in Jest 26-series packages.

Jest 25+ (more specifically its version of jsdom) appears to be required for running tests against React 17.

Related release notes:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions