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

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

Closed
Hotell opened this issue Feb 11, 2021 · 4 comments · Fixed by #21517
Closed

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

Hotell opened this issue Feb 11, 2021 · 4 comments · Fixed by #21517

Comments

@Hotell
Copy link
Contributor

Hotell commented Feb 11, 2021

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:

@ecraig12345
Copy link
Member

ecraig12345 commented Feb 11, 2021

(EDIT: now added to main description)

We can't use TS 3.9 because (short version) it will cause massive bundle size increases for consumers. The issue is fixed in 4.0. (Message me if you want an internal link with more details.)
microsoft/TypeScript#38696
webpack/webpack#10889

There was also some bug blocking 3.8, though unfortunately I don't remember what that was.

On initial investigation, bumping jest to 25 is likely to be doable apart from a TS upgrade, and desirable because I think it will unblock testing with react 17. Not sure how much that helps with testing-library (and definitely the goal is to get to jest 26 soon!).

@ecraig12345
Copy link
Member

@Hotell Should we close this now or repurpose to help track jest updates?

@Hotell
Copy link
Contributor Author

Hotell commented Jun 4, 2021

let's keep it open, thx.

@ecraig12345 ecraig12345 changed the title FAQ: migrate to jest 26/typescript >=3.8/testing-library >=11 FAQ: migrate to jest 27/testing-library >=11 Aug 27, 2021
@ecraig12345
Copy link
Member

Updated the description and title with current status--basically it's all unblocked now (at least from a typescript perspective) but nobody has had time to do it 😞

@msft-fluent-ui-bot msft-fluent-ui-bot added Status: Fixed Fixed in some PR and removed Status: In PR labels Feb 2, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants