Skip to content

Commit 5393395

Browse files
authored
Enable PPR in Dynamic IO tests (#79301)
To prepare for an upcoming change where `ppr` will be enabled automatically when `dynamicIO` is enabled, we're hard coding `ppr: true` in the Dynamic IO tests with this PR. The non-PPR assertions are subsequently removed, which makes up most of the changed lines. We can now also exclude the tests in the PPR tests manifest, so that they're not run twice in CI. > [!NOTE] > This PR is best reviewed with hidden whitespace changes.
1 parent 5442d09 commit 5393395

File tree

53 files changed

+1386
-3019
lines changed

Some content is hidden

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

53 files changed

+1386
-3019
lines changed

test/development/app-dir/dynamic-io-dev-cache-scope/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const nextConfig = {
55
experimental: {
66
dynamicIO: true,
7+
ppr: true,
78
},
89
}
910

test/development/app-dir/dynamic-io-dev-errors/next.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const nextConfig = {
55
experimental: {
66
dynamicIO: true,
7+
ppr: true,
78
},
89
}
910

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
experimental: {
33
dynamicIO: true,
4+
ppr: true,
45
},
56
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module.exports = {
22
experimental: {
33
dynamicIO: true,
4+
ppr: true,
45
},
56
}

test/e2e/app-dir/dynamic-io-dynamic-imports/bundled/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
prerenderEarlyExit: false,
99
},

test/e2e/app-dir/dynamic-io-dynamic-imports/dynamic-io-dynamic-imports.test.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ describe('async imports in dynamicIO', () => {
1717
await next.readFile('.next/prerender-manifest.json')
1818
)
1919

20-
let prerenderedRoutes = Object.keys(prerenderManifest.routes).sort()
21-
22-
if (process.env.__NEXT_EXPERIMENTAL_PPR === 'true') {
23-
// For the purpose of this test we don't consider an incomplete shell.
24-
prerenderedRoutes = prerenderedRoutes.filter((route) => {
20+
// For the purpose of this test we don't consider an incomplete shell.
21+
const prerenderedRoutes = Object.keys(prerenderManifest.routes)
22+
.sort()
23+
.filter((route) => {
2524
const filename = route.replace(/^\//, '').replace(/^$/, 'index')
2625
try {
2726
return next
@@ -37,7 +36,6 @@ describe('async imports in dynamicIO', () => {
3736
}
3837
}
3938
})
40-
}
4139

4240
expect(prerenderedRoutes).toMatchInlineSnapshot(`
4341
[

test/e2e/app-dir/dynamic-io-dynamic-imports/external/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
},
99
serverExternalPackages: ['external-esm-pkg-with-async-import'],

test/e2e/app-dir/dynamic-io-errors/dynamic-io-errors.platform-dynamic.test.ts

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { nextTestSetup } from 'e2e-utils'
22

3-
const WITH_PPR = !!process.env.__NEXT_EXPERIMENTAL_PPR
4-
53
const stackStart = /\s+at /
64

75
function createExpectError(cliOutput: string) {
@@ -75,15 +73,9 @@ function runTests(options: { withMinification: boolean }) {
7573
throw new Error('expected build not to fail for fully static project')
7674
}
7775

78-
if (WITH_PPR) {
79-
expect(next.cliOutput).toContain('◐ / ')
80-
const $ = await next.render$('/')
81-
expect($('[data-fallback]').length).toBe(2)
82-
} else {
83-
expect(next.cliOutput).toContain('ƒ / ')
84-
const $ = await next.render$('/')
85-
expect($('[data-fallback]').length).toBe(0)
86-
}
76+
expect(next.cliOutput).toContain('◐ / ')
77+
const $ = await next.render$('/')
78+
expect($('[data-fallback]').length).toBe(2)
8779
})
8880
})
8981

test/e2e/app-dir/dynamic-io-errors/dynamic-io-errors.sync-dynamic.test.ts

+9-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { nextTestSetup } from 'e2e-utils'
22

3-
const WITH_PPR = !!process.env.__NEXT_EXPERIMENTAL_PPR
4-
53
const stackStart = /\s+at /
64

75
function createExpectError(cliOutput: string) {
@@ -75,15 +73,9 @@ function runTests(options: { withMinification: boolean }) {
7573
throw new Error('expected build not to fail for fully static project')
7674
}
7775

78-
if (WITH_PPR) {
79-
expect(next.cliOutput).toContain('◐ / ')
80-
const $ = await next.render$('/')
81-
expect($('[data-fallback]').length).toBe(2)
82-
} else {
83-
expect(next.cliOutput).toContain('ƒ / ')
84-
const $ = await next.render$('/')
85-
expect($('[data-fallback]').length).toBe(2)
86-
}
76+
expect(next.cliOutput).toContain('◐ / ')
77+
const $ = await next.render$('/')
78+
expect($('[data-fallback]').length).toBe(2)
8779
})
8880
})
8981

@@ -162,15 +154,9 @@ function runTests(options: { withMinification: boolean }) {
162154
throw new Error('expected build not to fail for fully static project')
163155
}
164156

165-
if (WITH_PPR) {
166-
expect(next.cliOutput).toContain('◐ / ')
167-
const $ = await next.render$('/')
168-
expect($('[data-fallback]').length).toBe(2)
169-
} else {
170-
expect(next.cliOutput).toContain('ƒ / ')
171-
const $ = await next.render$('/')
172-
expect($('[data-fallback]').length).toBe(0)
173-
}
157+
expect(next.cliOutput).toContain('◐ / ')
158+
const $ = await next.render$('/')
159+
expect($('[data-fallback]').length).toBe(2)
174160
})
175161
})
176162

@@ -249,15 +235,9 @@ function runTests(options: { withMinification: boolean }) {
249235
throw new Error('expected build not to fail for fully static project')
250236
}
251237

252-
if (WITH_PPR) {
253-
expect(next.cliOutput).toContain('◐ / ')
254-
const $ = await next.render$('/')
255-
expect($('[data-fallback]').length).toBe(2)
256-
} else {
257-
expect(next.cliOutput).toContain('ƒ / ')
258-
const $ = await next.render$('/')
259-
expect($('[data-fallback]').length).toBe(0)
260-
}
238+
expect(next.cliOutput).toContain('◐ / ')
239+
const $ = await next.render$('/')
240+
expect($('[data-fallback]').length).toBe(2)
261241
})
262242
})
263243

test/e2e/app-dir/dynamic-io-errors/dynamic-io-errors.test.ts

+20-51
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { nextTestSetup } from 'e2e-utils'
22

3-
const WITH_PPR = !!process.env.__NEXT_EXPERIMENTAL_PPR
4-
53
const stackStart = /\s+at /
64

75
function createExpectError(cliOutput: string) {
@@ -205,16 +203,10 @@ function runTests(options: { withMinification: boolean }) {
205203
throw new Error('expected build not to fail for fully static project')
206204
}
207205

208-
if (WITH_PPR) {
209-
expect(next.cliOutput).toContain('◐ / ')
210-
const $ = await next.render$('/')
211-
expect($('#dynamic').text()).toBe('Dynamic')
212-
expect($('[data-fallback]').length).toBe(1)
213-
} else {
214-
expect(next.cliOutput).toContain('ƒ / ')
215-
const $ = await next.render$('/')
216-
expect($('#dynamic').text()).toBe('Dynamic')
217-
}
206+
expect(next.cliOutput).toContain('◐ / ')
207+
const $ = await next.render$('/')
208+
expect($('#dynamic').text()).toBe('Dynamic')
209+
expect($('[data-fallback]').length).toBe(1)
218210
})
219211
})
220212

@@ -379,16 +371,11 @@ function runTests(options: { withMinification: boolean }) {
379371
// Turbopack doesn't support disabling minification yet
380372
withMinification || isTurbopack ? undefined : 'IndirectionTwo'
381373
)
382-
if (WITH_PPR) {
383-
// React currently fatals the render in canary because we don't have access to the prerender API there. with a fatal only
384-
// one task actually reports and error at the moment. We should fix upstream but for now we exclude the second error when PPR is off
385-
// because we are using canary React and renderToReadableStream rather than experimental React and prerender
386-
expectError(
387-
'Route "/": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it.',
388-
// Turbopack doesn't support disabling minification yet
389-
withMinification || isTurbopack ? undefined : 'IndirectionThree'
390-
)
391-
}
374+
expectError(
375+
'Route "/": A component accessed data, headers, params, searchParams, or a short-lived cache without a Suspense boundary nor a "use cache" above it.',
376+
// Turbopack doesn't support disabling minification yet
377+
withMinification || isTurbopack ? undefined : 'IndirectionThree'
378+
)
392379
expectError('Error occurred prerendering page "/"')
393380
expectError('exiting the build.')
394381
})
@@ -421,36 +408,18 @@ function runTests(options: { withMinification: boolean }) {
421408
}
422409
})
423410

424-
if (WITH_PPR) {
425-
it('should partially prerender when all dynamic components are inside a Suspense boundary', async () => {
426-
try {
427-
await next.start()
428-
} catch {
429-
throw new Error(
430-
'expected build not to fail for fully static project'
431-
)
432-
// we expect the build to fail
433-
}
434-
435-
expect(next.cliOutput).toContain('◐ / ')
436-
const $ = await next.render$('/')
437-
expect($('[data-fallback]').length).toBe(2)
438-
})
439-
} else {
440-
it('should not error the build when all dynamic components are inside a Suspense boundary', async () => {
441-
try {
442-
await next.start()
443-
} catch {
444-
throw new Error(
445-
'expected build not to fail for fully static project'
446-
)
447-
}
411+
it('should partially prerender when all dynamic components are inside a Suspense boundary', async () => {
412+
try {
413+
await next.start()
414+
} catch {
415+
throw new Error('expected build not to fail for fully static project')
416+
// we expect the build to fail
417+
}
448418

449-
expect(next.cliOutput).toContain('ƒ / ')
450-
const $ = await next.render$('/')
451-
expect($('[data-fallback]').length).toBe(2)
452-
})
453-
}
419+
expect(next.cliOutput).toContain('◐ / ')
420+
const $ = await next.render$('/')
421+
expect($('[data-fallback]').length).toBe(2)
422+
})
454423
})
455424
})
456425
}

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-boundary/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-metadata-dynamic-route/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-metadata-error-route/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-metadata-static-route/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-metadata-static-with-suspense/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
pprFallbacks: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
88
dynamicIO: true,
99
serverMinification: true,

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-root/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: false,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-viewport-dynamic-route/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/dynamic-viewport-static-route/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/lazy-module-init/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: false,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/prospective-render-errors/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: false,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/static/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/sync-client-search-with-fallback/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/sync-client-search-without-fallback/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/sync-cookies-with-fallback/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

test/e2e/app-dir/dynamic-io-errors/fixtures/sync-cookies-without-fallback/next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
const nextConfig = {
55
experimental: {
6-
ppr: process.env.__NEXT_EXPERIMENTAL_PPR === 'true',
6+
ppr: true,
77
dynamicIO: true,
88
serverMinification: true,
99
},

0 commit comments

Comments
 (0)