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

refactor(test): drop global as any test modes #63244

Conversation

balazsorban44
Copy link
Member

@balazsorban44 balazsorban44 commented Mar 13, 2024

Closes NEXT-2800

Copy link
Member Author

balazsorban44 commented Mar 13, 2024

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @balazsorban44 and the rest of your teammates on Graphite Graphite

@ijjk
Copy link
Member

ijjk commented Mar 13, 2024

Stats from current PR

Default Build (Increase detected ⚠️)
General
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
buildDuration 13.9s 13.9s N/A
buildDurationCached 8.4s 6.3s N/A
nodeModulesSize 198 MB 198 MB
nextStartRea..uration (ms) 430ms 438ms N/A
Client Bundles (main, webpack)
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
2453-HASH.js gzip 30.4 kB 30.4 kB N/A
3304.HASH.js gzip 181 B 181 B
3f784ff6-HASH.js gzip 53.7 kB 53.7 kB N/A
8299-HASH.js gzip 5.04 kB 5.04 kB N/A
framework-HASH.js gzip 45.2 kB 45.2 kB
main-app-HASH.js gzip 242 B 242 B
main-HASH.js gzip 32.2 kB 32.2 kB N/A
webpack-HASH.js gzip 1.68 kB 1.68 kB N/A
Overall change 45.6 kB 45.6 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
polyfills-HASH.js gzip 31 kB 31 kB
Overall change 31 kB 31 kB
Client Pages
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
_app-HASH.js gzip 196 B 197 B N/A
_error-HASH.js gzip 184 B 184 B
amp-HASH.js gzip 505 B 505 B
css-HASH.js gzip 324 B 325 B N/A
dynamic-HASH.js gzip 2.5 kB 2.5 kB N/A
edge-ssr-HASH.js gzip 258 B 258 B
head-HASH.js gzip 352 B 352 B
hooks-HASH.js gzip 370 B 371 B N/A
image-HASH.js gzip 4.21 kB 4.21 kB
index-HASH.js gzip 259 B 259 B
link-HASH.js gzip 2.67 kB 2.67 kB N/A
routerDirect..HASH.js gzip 314 B 312 B N/A
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 309 B 309 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Overall change 6.57 kB 6.57 kB
Client Build Manifests
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
_buildManifest.js gzip 481 B 484 B N/A
Overall change 0 B 0 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
index.html gzip 530 B 527 B N/A
link.html gzip 541 B 540 B N/A
withRouter.html gzip 525 B 522 B N/A
Overall change 0 B 0 B
Edge SSR bundle Size
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
edge-ssr.js gzip 95.1 kB 95.1 kB N/A
page.js gzip 3.06 kB 3.07 kB N/A
Overall change 0 B 0 B
Middleware size
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
middleware-b..fest.js gzip 627 B 624 B N/A
middleware-r..fest.js gzip 151 B 151 B
middleware.js gzip 25.5 kB 25.5 kB N/A
edge-runtime..pack.js gzip 839 B 839 B
Overall change 990 B 990 B
Next Runtimes
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
app-page-exp...dev.js gzip 171 kB 171 kB
app-page-exp..prod.js gzip 96.6 kB 96.6 kB
app-page-tur..prod.js gzip 98.3 kB 98.3 kB
app-page-tur..prod.js gzip 92.8 kB 92.8 kB
app-page.run...dev.js gzip 149 kB 149 kB
app-page.run..prod.js gzip 91.3 kB 91.3 kB
app-route-ex...dev.js gzip 21.3 kB 21.3 kB
app-route-ex..prod.js gzip 15 kB 15 kB
app-route-tu..prod.js gzip 15 kB 15 kB
app-route-tu..prod.js gzip 14.8 kB 14.8 kB
app-route.ru...dev.js gzip 21 kB 21 kB
app-route.ru..prod.js gzip 14.8 kB 14.8 kB
pages-api-tu..prod.js gzip 9.52 kB 9.52 kB
pages-api.ru...dev.js gzip 9.8 kB 9.8 kB
pages-api.ru..prod.js gzip 9.52 kB 9.52 kB
pages-turbo...prod.js gzip 22.3 kB 22.3 kB
pages.runtim...dev.js gzip 22.9 kB 22.9 kB
pages.runtim..prod.js gzip 22.3 kB 22.3 kB
server.runti..prod.js gzip 50.5 kB 50.5 kB
Overall change 948 kB 948 kB
build cache Overall increase ⚠️
vercel/next.js canary vercel/next.js 03-13-refactor_test_drop_global_as_any_test_modes Change
0.pack gzip 1.56 MB 1.56 MB ⚠️ +1.1 kB
index.pack gzip 105 kB 105 kB ⚠️ +140 B
Overall change 1.66 MB 1.66 MB ⚠️ +1.24 kB
Diff details
Diff for middleware.js

Diff too large to display

Commit: ad39e17

@balazsorban44 balazsorban44 force-pushed the 03-13-refactor_test_use_imported_test_mode_instead_of_global_in_tests branch from 7cf1899 to 4c64c32 Compare March 13, 2024 18:09
@balazsorban44 balazsorban44 force-pushed the 03-13-refactor_test_use_imported_test_mode_instead_of_global_in_tests branch from 7947df5 to 76ed523 Compare March 13, 2024 18:27
@balazsorban44 balazsorban44 force-pushed the 03-13-refactor_test_drop_global_as_any_test_modes branch from a0263a1 to ad39e17 Compare March 13, 2024 18:27
@ijjk
Copy link
Member

ijjk commented Mar 13, 2024

Failing test suites

Commit: ad39e17

pnpm test-dev test/e2e/app-dir-legacy-edge-runtime-config/index.test.ts

  • app-dir edge runtime config > should warn the legacy object config export
Expand output

● app-dir edge runtime config › should warn the legacy object config export

expect(received).toBeDefined()

Received: undefined

  18 |         await next.fetch('/legacy-runtime-config')
  19 |       } else {
> 20 |         expect(error).toBeDefined()
     |                       ^
  21 |       }
  22 |
  23 |       expect(next.cliOutput).toContain('Page config in ')

  at Object.toBeDefined (e2e/app-dir-legacy-edge-runtime-config/index.test.ts:20:23)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/e2e/app-dir/app-compilation/index.test.ts

Expand output

● Test suite failed to run

Your test suite must contain at least one test.

  at onResult (../node_modules/.pnpm/@jest+core@29.7.0/node_modules/@jest/core/build/TestScheduler.js:133:18)
  at ../node_modules/.pnpm/@jest+core@29.7.0/node_modules/@jest/core/build/TestScheduler.js:254:19
  at ../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:363:13
      at Array.map (<anonymous>)
  at Emittery.emit (../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:361:23)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/errors/index.test.ts (PPR)

  • app-dir - errors > error component > should trigger error component when an error happens during server components rendering
  • app-dir - errors > error component > should use default error boundary for prod and overlay for dev when no error component specified
  • app-dir - errors > error component > should display error digest for error in server component with default error boundary
Expand output

● app-dir - errors › error component › should trigger error component when an error happens during server components rendering

expect(received).toBe(expected) // Object.is equality

Expected: "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
Received: "this is a test"

  51 |           expect(
  52 |             await browser.waitForElementByCss('#error-boundary-message').text()
> 53 |           ).toBe(
     |             ^
  54 |             'An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.'
  55 |           )
  56 |           expect(

  at Object.toBe (e2e/app-dir/errors/index.test.ts:53:13)

● app-dir - errors › error component › should use default error boundary for prod and overlay for dev when no error component specified

expect(received).toBe(expected) // Object.is equality

Expected: "Application error: a client-side exception has occurred (see the browser console for more information)."
Received: "Source"

  71 |           expect(
  72 |             await browser.waitForElementByCss('body').elementByCss('h2').text()
> 73 |           ).toBe(
     |             ^
  74 |             'Application error: a client-side exception has occurred (see the browser console for more information).'
  75 |           )
  76 |         }

  at Object.toBe (e2e/app-dir/errors/index.test.ts:73:13)

● app-dir - errors › error component › should display error digest for error in server component with default error boundary

expect(received).toBe(expected) // Object.is equality

Expected: "Application error: a server-side exception has occurred (see the server logs for more information)."
Received: "Source"

  86 |           expect(
  87 |             await browser.waitForElementByCss('body').elementByCss('h2').text()
> 88 |           ).toBe(
     |             ^
  89 |             'Application error: a server-side exception has occurred (see the server logs for more information).'
  90 |           )
  91 |           expect(

  at Object.toBe (e2e/app-dir/errors/index.test.ts:88:13)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/draft-mode/draft-mode.test.ts

  • app dir - draft mode > in nodejs runtime > should not generate rand when draft mode disabled during next start
Expand output

● app dir - draft mode › in nodejs runtime › should not generate rand when draft mode disabled during next start

expect(received).toBe(expected) // Object.is equality

Expected: "0.8045034031808338"
Received: "0.9595923371570843"

  33 |             const $ = await next.render$(basePath)
  34 |             expect($('#mode').text()).toBe('DISABLED')
> 35 |             expect($('#rand').text()).toBe(origRandHome)
     |                                       ^
  36 |           })
  37 |         }
  38 |

  at Object.toBe (e2e/app-dir/draft-mode/draft-mode.test.ts:35:39)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/global-error/layout-error/index.test.ts

  • app dir - global error - layout error > should render global error for error in server components
Expand output

● app dir - global error - layout error › should render global error for error in server components

expect(received).toBe(expected) // Object.is equality

Expected: "Global Error"
Received: "Unhandled Runtime Error"

  20 |         await testDev(browser, /Global error: layout error/)
  21 |       } else {
> 22 |         expect(await browser.elementByCss('h1').text()).toBe('Global Error')
     |                                                         ^
  23 |         expect(await browser.elementByCss('#error').text()).toBe(
  24 |           'Global error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.'
  25 |         )

  at Object.toBe (e2e/app-dir/global-error/layout-error/index.test.ts:22:57)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/e2e/favicon-short-circuit/favicon-short-circuit.test.ts

Expand output

● Test suite failed to run

Your test suite must contain at least one test.

  at onResult (../node_modules/.pnpm/@jest+core@29.7.0/node_modules/@jest/core/build/TestScheduler.js:133:18)
  at ../node_modules/.pnpm/@jest+core@29.7.0/node_modules/@jest/core/build/TestScheduler.js:254:19
  at ../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:363:13
      at Array.map (<anonymous>)
  at Emittery.emit (../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:361:23)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/e2e/app-dir/metadata-dynamic-routes/index.test.ts (PPR)

  • app dir - metadata dynamic routes > should inject dynamic metadata properly to head
Expand output

● app dir - metadata dynamic routes › should inject dynamic metadata properly to head

expect(received).toMatch(expected)

Expected pattern: /http:\/\/localhost:\d+\/opengraph-image\?/
Received string:  "https://mydomain.com/opengraph-image?539a41ff97692a86"

  375 |         twitterImageUrlPattern = /http:\/\/localhost:\d+\/twitter-image\?/
  376 |       }
> 377 |       expect(ogImageUrl).toMatch(ogImageUrlPattern)
      |                          ^
  378 |       expect(twitterImageUrl).toMatch(twitterImageUrlPattern)
  379 |       expect(ogImageUrl).toMatch(hashRegex)
  380 |       expect(twitterImageUrl).toMatch(hashRegex)

  at Object.toMatch (e2e/app-dir/metadata-dynamic-routes/index.test.ts:377:26)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/e2e/conflicting-app-page-error/index.test.ts (PPR)

Expand output

● Test suite failed to run

Your test suite must contain at least one test.

  at onResult (../node_modules/.pnpm/@jest+core@29.7.0/node_modules/@jest/core/build/TestScheduler.js:133:18)
  at ../node_modules/.pnpm/@jest+core@29.7.0/node_modules/@jest/core/build/TestScheduler.js:254:19
  at ../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:363:13
      at Array.map (<anonymous>)
  at Emittery.emit (../node_modules/.pnpm/emittery@0.13.1/node_modules/emittery/index.js:361:23)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/e2e/app-dir/app-static/app-static-custom-handler.test.ts

  • app-dir static/dynamic handling > should handle dynamicParams: false correctly
  • app-dir static/dynamic handling > should navigate to static path correctly
  • app-dir static/dynamic handling > should build dynamic param with edge runtime correctly
Expand output

● app-dir static/dynamic handling › should handle dynamicParams: false correctly

expect(received).toBe(expected) // Object.is equality

Expected: 200
Received: 404

  2706 |             redirect: 'manual',
  2707 |           })
> 2708 |           expect(res.status).toBe(200)
       |                              ^
  2709 |           const html = await res.text()
  2710 |           const $ = cheerio.load(html)
  2711 |

  at Object.toBe (e2e/app-dir/app-static/app-static.test.ts:2708:30)

● app-dir static/dynamic handling › should navigate to static path correctly

expect(received).toContain(expected) // indexOf

Expected substring: "/blog/[author]"
Received string:    "<head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><link rel=\"preload\" as=\"script\" fetchpriority=\"low\" href=\"/_next/static/chunks/webpack-0f3dc8da88f1c143.js\"><script src=\"/_next/static/chunks/0012b42e-b39b89f7c0a1d7b6.js\" async=\"\"></script><script src=\"/_next/static/chunks/7456-bcb320ce819d28f6.js\" async=\"\"></script><script src=\"/_next/static/chunks/main-app-00777b219aad55b4.js\" async=\"\"></script><meta name=\"robots\" content=\"noindex\"><title>404: This page could not be found.</title><title>my static blog</title><title>404: This page could not be found.</title><script src=\"/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js\" nomodule=\"\"></script></head><body><div style=\"font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center\"><div><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class=\"next-error-h1\" style=\"display:inline-block;margin:0 20px 0 0;padding:0 23px 0 0;font-size:24px;font-weight:500;vertical-align:top;line-height:49px\">404</h1><div style=\"display:inline-block\"><h2 style=\"font-size:14px;font-weight:400;line-height:49px;margin:0\">This page could not be found.</h2></div></div></div><script src=\"/_next/static/chunks/webpack-0f3dc8da88f1c143.js\" async=\"\"></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,\"1:I[7588,[],\\\"\\\"]\\n3:I[9943,[],\\\"\\\"]\\n4:I[272,[],\\\"\\\"]\\na:I[9863,[],\\\"\\\"]\\n5:{\\\"fontFamily\\\":\\\"system-ui,\\\\\\\"Segoe UI\\\\\\\",Roboto,Helvetica,Arial,sans-serif,\\\\\\\"Apple Color Emoji\\\\\\\",\\\\\\\"Segoe UI Emoji\\\\\\\"\\\",\\\"height\\\":\\\"100vh\\\",\\\"textAlign\\\":\\\"center\\\",\\\"display\\\":\\\"flex\\\",\\\"flexDirection\\\":\\\"column\\\",\\\"alignItems\\\":\\\"center\\\",\\\"justifyContent\\\":\\\"center\\\"}\\n6:{\\\"display\\\":\\\"inline-block\\\",\\\"margin\\\":\\\"0 20px 0 0\\\",\\\"padding\\\":\\\"0 23px 0 0\\\",\\\"fontSize\\\":24,\\\"fontWeight\\\":500,\\\"verticalAlign\\\":\\\"top\\\",\\\"lineHeight\\\":\\\"49px\\\"}\\n7:{\\\"display\\\":\\\"inline-block\\\"}\\n8:{\\\"fontSize\\\":14,\\\"fontWeight\"])</script><script>self.__next_f.push([1,\"\\\":400,\\\"lineHeight\\\":\\\"49px\\\",\\\"margin\\\":0}\\nb:[]\\n\"])</script><script>self.__next_f.push([1,\"0:[null,[\\\"$\\\",\\\"$L1\\\",null,{\\\"buildId\\\":\\\"LTE8DBfU67AbmVCIueG1Z\\\",\\\"assetPrefix\\\":\\\"\\\",\\\"initialCanonicalUrl\\\":\\\"/blog/tim\\\",\\\"initialTree\\\":[\\\"\\\",{\\\"children\\\":[\\\"/_not-found\\\",{\\\"children\\\":[\\\"__PAGE__\\\",{}]}]},\\\"$undefined\\\",\\\"$undefined\\\",true],\\\"initialSeedData\\\":[\\\"\\\",{\\\"children\\\":[\\\"/_not-found\\\",{\\\"children\\\":[\\\"__PAGE__\\\",{},[[\\\"$L2\\\",[[\\\"$\\\",\\\"title\\\",null,{\\\"children\\\":\\\"404: This page could not be found.\\\"}],[\\\"$\\\",\\\"div\\\",null,{\\\"style\\\":{\\\"fontFamily\\\":\\\"system-ui,\\\\\\\"Segoe UI\\\\\\\",Roboto,Helvetica,Arial,sans-serif,\\\\\\\"Apple Color Emoji\\\\\\\",\\\\\\\"Segoe UI Emoji\\\\\\\"\\\",\\\"height\\\":\\\"100vh\\\",\\\"textAlign\\\":\\\"center\\\",\\\"display\\\":\\\"flex\\\",\\\"flexDirection\\\":\\\"column\\\",\\\"alignItems\\\":\\\"center\\\",\\\"justifyContent\\\":\\\"center\\\"},\\\"children\\\":[\\\"$\\\",\\\"div\\\",null,{\\\"children\\\":[[\\\"$\\\",\\\"style\\\",null,{\\\"dangerouslySetInnerHTML\\\":{\\\"__html\\\":\\\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\\\"}}],[\\\"$\\\",\\\"h1\\\",null,{\\\"className\\\":\\\"next-error-h1\\\",\\\"style\\\":{\\\"display\\\":\\\"inline-block\\\",\\\"margin\\\":\\\"0 20px 0 0\\\",\\\"padding\\\":\\\"0 23px 0 0\\\",\\\"fontSize\\\":24,\\\"fontWeight\\\":500,\\\"verticalAlign\\\":\\\"top\\\",\\\"lineHeight\\\":\\\"49px\\\"},\\\"children\\\":\\\"404\\\"}],[\\\"$\\\",\\\"div\\\",null,{\\\"style\\\":{\\\"display\\\":\\\"inline-block\\\"},\\\"children\\\":[\\\"$\\\",\\\"h2\\\",null,{\\\"style\\\":{\\\"fontSize\\\":14,\\\"fontWeight\\\":400,\\\"lineHeight\\\":\\\"49px\\\",\\\"margin\\\":0},\\\"children\\\":\\\"This page could not be found.\\\"}]}]]}]}]]],null]]},[\\\"$\\\",\\\"$L3\\\",null,{\\\"parallelRouterKey\\\":\\\"children\\\",\\\"segmentPath\\\":[\\\"children\\\",\\\"/_not-found\\\",\\\"children\\\"],\\\"loading\\\":\\\"$undefined\\\",\\\"loadingStyles\\\":\\\"$undefined\\\",\\\"loadingScripts\\\":\\\"$undefined\\\",\\\"hasLoading\\\":false,\\\"error\\\":\\\"$undefined\\\",\\\"errorStyles\\\":\\\"$undefined\\\",\\\"errorScripts\\\":\\\"$undefined\\\",\\\"template\\\":[\\\"$\\\",\\\"$L4\\\",null,{}],\\\"templateStyles\\\":\\\"$undefined\\\",\\\"templateScripts\\\":\\\"$undefined\\\",\\\"notFound\\\":\\\"$undefined\\\",\\\"notFoundStyles\\\":\\\"$undefined\\\",\\\"styles\\\":null}]]},[[\\\"$\\\",\\\"html\\\",null,{\\\"lang\\\":\\\"en\\\",\\\"children\\\":[[\\\"$\\\",\\\"head\\\",null,{\\\"children\\\":[\\\"$\\\",\\\"title\\\",null,{\\\"children\\\":\\\"my static blog\\\"}]}],[\\\"$\\\",\\\"body\\\",null,{\\\"children\\\":[\\\"$\\\",\\\"$L3\\\",null,{\\\"parallelRouterKey\\\":\\\"children\\\",\\\"segmentPath\\\":[\\\"children\\\"],\\\"loading\\\":\\\"$undefined\\\",\\\"loadingStyles\\\":\\\"$undefined\\\",\\\"loadingScripts\\\":\\\"$undefined\\\",\\\"hasLoading\\\":false,\\\"error\\\":\\\"$undefined\\\",\\\"errorStyles\\\":\\\"$undefined\\\",\\\"errorScripts\\\":\\\"$undefined\\\",\\\"template\\\":[\\\"$\\\",\\\"$L4\\\",null,{}],\\\"templateStyles\\\":\\\"$undefined\\\",\\\"templateScripts\\\":\\\"$undefined\\\",\\\"notFound\\\":[[\\\"$\\\",\\\"title\\\",null,{\\\"children\\\":\\\"404: This page could not be found.\\\"}],[\\\"$\\\",\\\"div\\\",null,{\\\"style\\\":\\\"$5\\\",\\\"children\\\":[\\\"$\\\",\\\"div\\\",null,{\\\"children\\\":[[\\\"$\\\",\\\"style\\\",null,{\\\"dangerouslySetInnerHTML\\\":{\\\"__html\\\":\\\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\\\"}}],[\\\"$\\\",\\\"h1\\\",null,{\\\"className\\\":\\\"next-error-h1\\\",\\\"style\\\":\\\"$6\\\",\\\"children\\\":\\\"404\\\"}],[\\\"$\\\",\\\"div\\\",null,{\\\"style\\\":\\\"$7\\\",\\\"children\\\":[\\\"$\\\",\\\"h2\\\",null,{\\\"style\\\":\\\"$8\\\",\\\"children\\\":\\\"This page could not be found.\\\"}]}]]}]}]],\\\"notFoundStyles\\\":[],\\\"styles\\\":null}]}]]}],null]],\\\"couldBeIntercepted\\\":false,\\\"initialHead\\\":[[\\\"$\\\",\\\"meta\\\",null,{\\\"name\\\":\\\"robots\\\",\\\"content\\\":\\\"noindex\\\"}],\\\"$L9\\\"],\\\"globalErrorComponent\\\":\\\"$a\\\",\\\"missingSlots\\\":\\\"$Wb\\\"}]]\\n\"])</script><script>self.__next_f.push([1,\"9:[[\\\"$\\\",\\\"meta\\\",\\\"0\\\",{\\\"name\\\":\\\"viewport\\\",\\\"content\\\":\\\"width=device-width, initial-scale=1\\\"}],[\\\"$\\\",\\\"meta\\\",\\\"1\\\",{\\\"charSet\\\":\\\"utf-8\\\"}]]\\n2:null\\n\"])</script><next-route-announcer style=\"position: absolute;\"></next-route-announcer></body>"

  2789 |         expect(
  2790 |           await browser.eval('document.documentElement.innerHTML')
> 2791 |         ).toContain('/blog/[author]')
       |           ^
  2792 |         await browser.elementByCss('#author-2').click()
  2793 |
  2794 |         await check(async () => {

  at Object.toContain (e2e/app-dir/app-static/app-static.test.ts:2791:11)

● app-dir static/dynamic handling › should build dynamic param with edge runtime correctly

page.evaluate: Target page, context or browser has been closed

  482 |
  483 |   async url() {
> 484 |     return this.chain(() => page.evaluate('window.location.href')) as any
      |                                  ^
  485 |   }
  486 |
  487 |   async waitForIdleNetwork(): Promise<void> {

  at evaluate (lib/browsers/playwright.ts:484:34)

Read more about building and testing Next.js in contributing.md.

pnpm test-start test/e2e/app-dir/app-static/app-static.test.ts (PPR)

  • app-dir static/dynamic handling > should honor fetch cache in generateStaticParams
  • app-dir static/dynamic handling > should build dynamic param with edge runtime correctly
Expand output

● app-dir static/dynamic handling › should honor fetch cache in generateStaticParams

TypeError: Cannot read properties of undefined (reading 'routes')

  2166 |           // in separate workers so parse value from
  2167 |           // prerender-manifest
> 2168 |           const routes = Object.keys(prerenderManifest.routes)
       |                                                        ^
  2169 |
  2170 |           for (const route of routes) {
  2171 |             const langSlug = route.match(

  at Object.routes (e2e/app-dir/app-static/app-static.test.ts:2168:56)

● app-dir static/dynamic handling › should build dynamic param with edge runtime correctly

page.evaluate: Target page, context or browser has been closed

  482 |
  483 |   async url() {
> 484 |     return this.chain(() => page.evaluate('window.location.href')) as any
      |                                  ^
  485 |   }
  486 |
  487 |   async waitForIdleNetwork(): Promise<void> {

  at evaluate (lib/browsers/playwright.ts:484:34)

Read more about building and testing Next.js in contributing.md.

pnpm test-dev test/e2e/app-dir/conflicting-page-segments/conflicting-page-segments.test.ts (PPR)

  • conflicting-page-segments > should throw an error when a route groups causes a conflict with a parallel segment
Expand output

● conflicting-page-segments › should throw an error when a route groups causes a conflict with a parallel segment

expect(received).rejects.toThrow()

Received promise resolved instead of rejected
Resolved to value: undefined

  20 |         )
  21 |       } else {
> 22 |         await expect(next.start()).rejects.toThrow('next build failed')
     |               ^
  23 |
  24 |         await check(
  25 |           () => next.cliOutput,

  at expect (../node_modules/.pnpm/expect@29.7.0/node_modules/expect/build/index.js:113:15)
  at Object.expect (e2e/app-dir/conflicting-page-segments/conflicting-page-segments.test.ts:22:15)

Read more about building and testing Next.js in contributing.md.

TURBOPACK=1 pnpm test-dev test/e2e/app-dir/dynamic-data/dynamic-data.test.ts (turbopack)

  • dynamic-data > should render empty objects for dynamic APIs when rendering with force-static
  • dynamic-data > should track dynamic apis when rendering app routes
  • dynamic-data inside cache scope > error when the build when accessing dynamic data inside a cache scope
  • dynamic-data with dynamic = "error" > error when the build when dynamic = "error" and dynamic data is read
Expand output

● dynamic-data › should render empty objects for dynamic APIs when rendering with force-static

expect(received).toBe(expected) // Object.is equality

Expected: "build"
Received: "run"

  116 |       } else {
  117 |         // in static generation we expect the entire page to be rendered at runtime
> 118 |         expect($('#layout').text()).toBe('build')
      |                                     ^
  119 |         expect($('#page').text()).toBe('build')
  120 |         // we expect there to be no suspense boundary in fallback state
  121 |         expect($('#boundary').html()).toBeNull()

  at Object.toBe (e2e/app-dir/dynamic-data/dynamic-data.test.ts:118:37)

● dynamic-data › should track dynamic apis when rendering app routes

expect(received).toContain(expected) // indexOf

Expected substring: "Caught Error: Dynamic server usage: Route /routes/url couldn't be rendered statically because it accessed `request.url`."
Received string:    "yarn run v1.22.19
$ /tmp/next-install-33fedcdd238ece5d7f5ef8312f8ceed751fd5438ebd62db345c19e5f08686e75/node_modules/.bin/next --turbo
   ▲ Next.js 14.2.0-canary.20 (turbo)
   - Local:        http://localhost:33451·
Creating turbopack project {
  dir: '/tmp/next-install-33fedcdd238ece5d7f5ef8312f8ceed751fd5438ebd62db345c19e5f08686e75',
  testMode: true
}
 ✓ Ready in 1165ms
 ✓ Compiled /setenv in 84ms
 ○ Compiling /top-level ...
 ✓ Compiled /top-level in 1822ms
 ✓ Compiled /force-dynamic in 126ms
 ✓ Compiled /force-static in 124ms
 ✓ Compiled /client-page in 145ms
"

  163 |     if (!isNextDev) {
  164 |       it('should track dynamic apis when rendering app routes', async () => {
> 165 |         expect(next.cliOutput).toContain(
      |                                ^
  166 |           `Caught Error: Dynamic server usage: Route /routes/url couldn't be rendered statically because it accessed \`request.url\`.`
  167 |         )
  168 |         expect(next.cliOutput).toContain(

  at Object.toContain (e2e/app-dir/dynamic-data/dynamic-data.test.ts:165:32)

● dynamic-data with dynamic = "error" › error when the build when dynamic = "error" and dynamic data is read

expect(received).toMatch(expected)

Expected substring: "Error: Route /cookies with `dynamic = \"error\"` couldn't be rendered statically because it used `cookies`"
Received string:    "yarn run v1.22.19
$ /tmp/next-install-8d97532875d1eea2ae274f0af930fc9981113b2c807681ee99090ec6fe27b762/node_modules/.bin/next --turbo
   ▲ Next.js 14.2.0-canary.20 (turbo)
   - Local:        http://localhost:45485·
"

  230 |         }
  231 |         // Error: Page with `dynamic = "error"` couldn't be rendered statically because it used `headers`
> 232 |         expect(next.cliOutput).toMatch(
      |                                ^
  233 |           'Error: Route /cookies with `dynamic = "error"` couldn\'t be rendered statically because it used `cookies`'
  234 |         )
  235 |         expect(next.cliOutput).toMatch(

  at Object.toMatch (e2e/app-dir/dynamic-data/dynamic-data.test.ts:232:32)

● dynamic-data inside cache scope › error when the build when accessing dynamic data inside a cache scope

expect(received).toMatch(expected)

Expected substring: "Error: Route /cookies used \"cookies\" inside a function cached with \"unstable_cache(...)\"."
Received string:    "yarn run v1.22.19
$ /tmp/next-install-3348cf7155843dffdf0553aa23672f4ce9f91dca74c54c9c42a479ae484eff63/node_modules/.bin/next --turbo
   ▲ Next.js 14.2.0-canary.20 (turbo)
   - Local:        http://localhost:44347·
"

  295 |           // We expect this to fail
  296 |         }
> 297 |         expect(next.cliOutput).toMatch(
      |                                ^
  298 |           'Error: Route /cookies used "cookies" inside a function cached with "unstable_cache(...)".'
  299 |         )
  300 |         expect(next.cliOutput).toMatch(

  at Object.toMatch (e2e/app-dir/dynamic-data/dynamic-data.test.ts:297:32)

Read more about building and testing Next.js in contributing.md.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants