Unverified Commit 93eaf146 authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[test] Add test for static metadata files and `generateStaticParams` (#93465)

parent 4797acb8
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
export function generateStaticParams() {
return [{ id: 'one' }, { id: 'two' }]
}
export default async function Page({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
return <p>result: {id}</p>
}
import { nextTestSetup } from 'e2e-utils'
describe('metadata-static-file-gsp', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
})
if (skipped) {
return
}
it('should build and serve a static metadata file colocated with generateStaticParams', async () => {
await next.render('/results/two')
})
})
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}
module.exports = nextConfig
...@@ -6,28 +6,6 @@ import { ...@@ -6,28 +6,6 @@ import {
} from './utils' } from './utils'
describe('metadata-files-static-output-dynamic-route', () => { describe('metadata-files-static-output-dynamic-route', () => {
if (process.env.__NEXT_CACHE_COMPONENTS) {
// Cache Components build fails when metadata files are inside a dynamic route.
//
// Route "/dynamic/[id]": Next.js encountered uncached or runtime data in `generateMetadata()`.
//
// This prevents the page from being prerendered, leading to a slower user experience.
//
// Ways to fix this:
// - Use a static metadata export instead of `generateMetadata()`
// - Cache the metadata with `"use cache"` in `generateMetadata()`
// - Add a dynamic data access (e.g. `await connection()`) to the page to render it at request time
// - Set `export const instant = false` to allow a blocking route
//
// Learn more: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata
// Error occurred prerendering page "/dynamic/[id]". Read more: https://nextjs.org/docs/messages/prerender-error
// Export encountered an error on /dynamic/[id]/page: /dynamic/[id], exiting the build.
//
// TODO: Remove this skip when metadata files are supported in dynamic routes for Cache Components.
it.skip('should skip test for Cache Components', () => {})
return
}
const { next, skipped } = nextTestSetup({ const { next, skipped } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment