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

Build: Upgrade Jest to 29 #19863

Merged
merged 11 commits into from
Nov 17, 2022
Merged

Build: Upgrade Jest to 29 #19863

merged 11 commits into from
Nov 17, 2022

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Nov 17, 2022

Issue:

What I did

This bumps jest to the latest version, 29.3.1, along with a few other related jest packages.

I needed to break up the config a little, because I started getting validation messages about the "global" config options that I needed to move to the top level.

How to test

  • CI

@IanVS IanVS added the build Internal-facing build tooling & test updates label Nov 17, 2022
@kasperpeulen
Copy link
Contributor

@IanVS Just did a quick commit, to see if we can remove run in band with jest 29, to see if we can speed things up again in CI.

@IanVS
Copy link
Member Author

IanVS commented Nov 17, 2022

to see if we can speed things up again in CI.

Do we know for sure that the flag slowed things down? It seemed like it was finishing in approximately the same time as before, given that we are now running a few more tests as well.

@kasperpeulen
Copy link
Contributor

kasperpeulen commented Nov 17, 2022

@IanVS Removing runInBand made it crash indeed, but setting maxWorkers=4 seems to be green:

image

When I initially removed runInBand a couple of weeks ago, I saw a consistent 2.6 improvement. Just comparing those 2 gives 2.4 time improvement.

I think by default it will use 7 workers (given 8 cores in xlarge).

@kasperpeulen kasperpeulen marked this pull request as ready for review November 17, 2022 18:09
@kasperpeulen kasperpeulen self-requested a review November 17, 2022 18:10
Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

LGTM!

@IanVS
Copy link
Member Author

IanVS commented Nov 17, 2022

We will also want to update igor-dv/jest-specific-snapshot#44 once it's merged and released, but I don't think it needs to block this PR.

@@ -82,7 +82,7 @@
"@storybook/theming": "7.0.0-alpha.50",
"@storybook/types": "7.0.0-alpha.50",
"global": "^4.4.0",
"jest-mock": "^27.0.6",
"jest-mock": "^29.3.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we can update this, since it's an actual dependency that is used by the interactions addon, and so far it only supports jest 27, AFAIK

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, will downgrade, cc @yannbf

@kasperpeulen kasperpeulen merged commit 609ba77 into next Nov 17, 2022
@kasperpeulen kasperpeulen deleted the upgrade-jest-29 branch November 17, 2022 21:43
@SimenB
Copy link
Contributor

SimenB commented Dec 1, 2022

🎉

Is it on purpose this was skipped?

@IanVS
Copy link
Member Author

IanVS commented Dec 1, 2022

@SimenB no, thanks for the catch. I think I missed it since I was searching for dependencies with the string jest.

@@ -85,7 +85,7 @@
},
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.19.0",
"@jest/transform": "^28.0.0",
"@jest/transform": "^29.3.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

@kasperpeulen I see that you updated @jest/transform here and in storyshots. Was that intentional? This is a dependency that is used by addon-docs, and my storybook is now crashing with an error message coming from jest-util via @jest/transform.

Uncaught TypeError: Cannot read properties of undefined (reading 'isTTY')
    at ./node_modules/jest-util/build/isInteractive.js 

Seems to come from https://github.com/facebook/jest/blob/e7edb75f8357090714213f252c5aaaa9b3c29f5f/packages/jest-util/src/isInteractive.ts#L10. We can't run that in the browser, since process isn't defined there.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm... intentional in the sense that I thought it would be nice to upgrade all the jest-related deps from 28 to 29, but I don't know about this package. So downgrading seems fine to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

should be trivial to replace process with a fake object for browser usage, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm sure we can deal with it, yes. I just like to keep user facing changes separate from internal test updates.

@SimenB since you're here, is this something that changed from 28 to 29? I took a quick look and couldn't immediately figure out why this would start to fail now in 29. Maybe you know offhand?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, I upgraded to the latest beta (beta.8), and I no longer get this error. I guess we can just keep our eyes out for it again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing comes to mind, that code has been the same for years

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Internal-facing build tooling & test updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants