Skip to content

Commit 33db463

Browse files
chore: upgrade jest (#56909)
### 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.
1 parent dc7bc70 commit 33db463

File tree

52 files changed

+2422
-2608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2422
-2608
lines changed

jest.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ const customJestConfig = {
1717
modulePathIgnorePatterns: ['/\\.next/'],
1818
modulePaths: ['<rootDir>/lib'],
1919
transformIgnorePatterns: ['/next[/\\\\]dist/', '/\\.next/'],
20-
globals: {
21-
AbortSignal: global.AbortSignal,
22-
},
2320
moduleNameMapper: {
2421
'@next/font/(.*)': '@next/font/$1',
2522
},

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"@types/glob": "7.1.1",
9898
"@types/html-validator": "5.0.3",
9999
"@types/http-proxy": "1.17.3",
100-
"@types/jest": "27.4.1",
100+
"@types/jest": "29.5.5",
101101
"@types/node": "20.2.5",
102102
"@types/node-fetch": "2.6.1",
103103
"@types/react": "18.2.28",
@@ -158,8 +158,9 @@
158158
"image-size": "0.9.3",
159159
"is-animated": "2.0.2",
160160
"isomorphic-unfetch": "3.0.0",
161-
"jest": "27.0.6",
162-
"jest-extended": "1.2.1",
161+
"jest": "29.7.0",
162+
"jest-environment-jsdom": "29.7.0",
163+
"jest-extended": "4.0.2",
163164
"jest-junit": "16.0.0",
164165
"json5": "2.2.3",
165166
"ky": "0.19.1",

packages/font/src/local/loader.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('next/font/local loader', () => {
8282

8383
expect(css).toMatchInlineSnapshot(`
8484
"@font-face {
85-
font-feature-settings: \\"smcp\\" on;
85+
font-feature-settings: "smcp" on;
8686
ascent-override: 90%;
8787
font-family: myFont;
8888
src: url(/_next/static/media/my-font.woff2) format('woff2');

packages/next/src/build/webpack/loaders/metadata/resolve-route-data.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ describe('resolveRouteData', () => {
8787
},
8888
])
8989
).toMatchInlineSnapshot(`
90-
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
91-
<urlset xmlns=\\"http://www.sitemaps.org/schemas/sitemap/0.9\\">
90+
"<?xml version="1.0" encoding="UTF-8"?>
91+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
9292
<url>
9393
<loc>https://example.com</loc>
9494
<lastmod>2021-01-01</lastmod>

packages/next/src/client/components/router-reducer/fill-cache-with-data-property.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ describe('fillCacheWithDataProperty', () => {
7373
)
7474

7575
expect(cache).toMatchInlineSnapshot(`
76-
Object {
76+
{
7777
"data": null,
7878
"parallelRoutes": Map {
7979
"children" => Map {
80-
"linking" => Object {
80+
"linking" => {
8181
"data": null,
8282
"parallelRoutes": Map {
8383
"children" => Map {
84-
"" => Object {
84+
"" => {
8585
"data": null,
8686
"parallelRoutes": Map {},
8787
"status": "READY",
@@ -96,7 +96,7 @@ describe('fillCacheWithDataProperty', () => {
9696
Linking
9797
</React.Fragment>,
9898
},
99-
"dashboard" => Object {
99+
"dashboard" => {
100100
"data": Promise {
101101
"status": "pending",
102102
},

0 commit comments

Comments
 (0)