-
Notifications
You must be signed in to change notification settings - Fork 28.4k
chore: upgrade jest
#56909
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
chore: upgrade jest
#56909
Conversation
Tests Passed |
Stats from current PRDefault BuildGeneral
Client Bundles (main, webpack)
Legacy Client Bundles (polyfills)
Client Pages
Client Build Manifests
Rendered Page Sizes
Edge SSR bundle Size
Middleware size
|
@@ -1062,7 +1062,7 @@ export async function getRedboxComponentStack( | |||
*/ | |||
export const describeVariants = { | |||
each(variants: TestVariants[]) { | |||
return (name: string, fn: (...args: TestVariants[]) => any) => { | |||
return (name: string, fn: (variants: TestVariants) => any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to tweak TS here
test/jest.d.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inlined in tsconfig.json
. See: https://github.com/vercel/next.js/pull/56909/files#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0R13
globals: { | ||
AbortSignal: global.AbortSignal, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can get rid of this thanks to https://jestjs.io/blog/2022/04/25/jest-28#all-nodejs-globals
### What? Note: This is not a breaking change, just removing some unused code. ### Why? Since #56896 we don't need this, as Node.js 18+ has `fetch` exposed by default. ### How? Depends on #56896, #56909 We already didn't load `fetch` if `globalThis` had it (ie. Node.js 18+ environments), and since we are dropping support for Node.js 16, these code paths should have no effect on runtime behavior.
What?
Upgrade jest to its latest version
Why?
#56899 fails because historically Jest stripped the globals in Node.js, but 28+ isn't doing that anymore. If we upgrade, we don't have to keep track of Node.js globals and when they are added. This will be useful in removing even more polyfills for things that are natively shipped in Node.js now.
How?
Jest 29 introduced a change to the snapshot format: https://jestjs.io/blog/2022/08/25/jest-29
First, I tried setting the old compat option to not require updating snapshots, but some tests were still failing: https://dev.azure.com/nextjs/next.js/_build/results?buildId=70633&view=logs&j=8af7cf9c-43a1-584d-6f5c-57bad8880974&t=7ae70e63-3625-50f4-6764-5b3e72b4bd7a&l=273 So going through the pain now instead.