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

Upgrade Jest to v28 #169

Merged
merged 3 commits into from
Jun 7, 2022
Merged

Upgrade Jest to v28 #169

merged 3 commits into from
Jun 7, 2022

Conversation

nmanu1
Copy link
Contributor

@nmanu1 nmanu1 commented Jun 6, 2022

This PR upgrades Jest from v27 to v28. Most of the breaking changes don't affect us, except for two:

  • To use the JSDOM test environment, jest-environment-jsdom now has to be installed separately
  • Jest now has full support for package exports, which can cause problems where file imports are not resolved correctly. Specifically, this is a problem for uuid. There is a discussion and proposed solution in this GitHub issue, which I used in this PR. To summarize, the fix is to add a custom resolver that forces Jest to use the CommonJS+node version of uuid, but leaves all other resolutions the same

J=SLAP-2123
TEST=auto

See that Jest tests pass.

@nmanu1 nmanu1 requested a review from a team as a code owner June 6, 2022 21:14
@coveralls
Copy link

coveralls commented Jun 6, 2022

Pull Request Test Coverage Report for Build 2455245851

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 71.148%

Totals Coverage Status
Change from base Build 2455035478: 0.0%
Covered Lines: 890
Relevant Lines: 1170

💛 - Coveralls

@@ -0,0 +1,31 @@
// This code is from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to use moduleNameMapper instead like suggested here? uuidjs/uuid#616 (comment)
It might be a little easier to find and remove later on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ridiculous they haven't closed out uuidjs/uuid#616 for 4 months

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible to use moduleNameMapper, but it seemed like that might have some consequences, discussed here: uuidjs/uuid#616 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, sgtm!

@nmanu1 nmanu1 requested a review from oshi97 June 7, 2022 14:23
@nmanu1 nmanu1 merged commit dd751c1 into main Jun 7, 2022
@nmanu1 nmanu1 deleted the dev/upgrade-jest branch June 7, 2022 15:30
yen-tt pushed a commit that referenced this pull request Sep 28, 2022
This PR upgrades Jest from v27 to v28. Most of the breaking changes don't affect us, except for two:
- To use the JSDOM test environment, `jest-environment-jsdom` now has to be installed separately
- Jest now has full support for package exports, which can cause problems where file imports are not resolved correctly. Specifically, this is a problem for `uuid`. There is a discussion and proposed solution in this [GitHub issue](microsoft/accessibility-insights-web#5421 (comment)), which I used in this PR. To summarize, the fix is to add a custom resolver that forces Jest to use the CommonJS+node version of `uuid`, but leaves all other resolutions the same

J=SLAP-2123
TEST=auto

See that Jest tests pass.
@nmanu1 nmanu1 mentioned this pull request Sep 29, 2022
nmanu1 added a commit that referenced this pull request Sep 30, 2022
Upgrade Jest from v27 to v29. We had [previously](#169) upgraded Jest to v28, but had to [downgrade](#275) to v27 because at the time, `@storybook/test-runner` only supported up to v27. In v0.7 of `@storybook/test-runner`, they changed Jest to be an internal dependency instead of a peer dependency, allowing us to use whatever version of Jest we want.

There was only one breaking change in v29 that affected our code, besides those that already needed to be made when upgrading from v27 to v28 (see previous PR [description](#169 (comment))). This was the `jsdom` upgrade from v19 to v20 in `jest-environment-jsdom`, which requires the `typescript` version to be 4.5 or higher.

With the new support added in v29 and `uuid` v9, we are now able to remove the manual resolving needed in `tests/__setup__/resolver.ts`. For more context on why this was initially needed with Jest v28, see #169.

J=SLAP-2376
TEST=manual

See that existing tests still run properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants