-
Notifications
You must be signed in to change notification settings - Fork 27.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dynamicIO]: dev navigations should show disallowed dynamic errors
- Loading branch information
Showing
7 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
test/development/app-dir/dynamic-io-dev-errors/app/error/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default async function Page() { | ||
const random = Math.random() | ||
return <div id="another-random">{random}</div> | ||
} |
9 changes: 9 additions & 0 deletions
9
test/development/app-dir/dynamic-io-dev-errors/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default function Root({ children }: { children: React.ReactNode }) { | ||
return ( | ||
<html> | ||
<body> | ||
<main>{children}</main> | ||
</body> | ||
</html> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
test/development/app-dir/dynamic-io-dev-errors/app/no-error/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Link from 'next/link' | ||
|
||
export default async function Page() { | ||
return <Link href="/error">To /error</Link> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Link from 'next/link' | ||
|
||
export default async function Page() { | ||
return <Link href="/no-error">To /no-error</Link> | ||
} |
45 changes: 45 additions & 0 deletions
45
test/development/app-dir/dynamic-io-dev-errors/dynamic-io-dev-errors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import { | ||
getRedboxDescription, | ||
hasErrorToast, | ||
retry, | ||
waitForAndOpenRuntimeError, | ||
} from 'next-test-utils' | ||
|
||
describe('Dynamic IO Dev Errors', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
}) | ||
|
||
it('should show a red box error on the SSR render', async () => { | ||
const browser = await next.browser('/error') | ||
|
||
await retry(async () => { | ||
expect(await hasErrorToast(browser)).toBe(true) | ||
|
||
await waitForAndOpenRuntimeError(browser) | ||
|
||
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot( | ||
`"[ Server ] Error: Route "/error" used \`Math.random()\` outside of \`"use cache"\` and without explicitly calling \`await connection()\` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random"` | ||
) | ||
}) | ||
}) | ||
|
||
it('should show a red box error on client navigations', async () => { | ||
const browser = await next.browser('/no-error') | ||
|
||
expect(await hasErrorToast(browser)).toBe(false) | ||
|
||
await browser.elementByCss("[href='/error']").click() | ||
|
||
await retry(async () => { | ||
expect(await hasErrorToast(browser)).toBe(true) | ||
|
||
await waitForAndOpenRuntimeError(browser) | ||
|
||
expect(await getRedboxDescription(browser)).toMatchInlineSnapshot( | ||
`"[ Server ] Error: Route "/error" used \`Math.random()\` outside of \`"use cache"\` and without explicitly calling \`await connection()\` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random"` | ||
) | ||
}) | ||
}) | ||
}) |
10 changes: 10 additions & 0 deletions
10
test/development/app-dir/dynamic-io-dev-errors/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
experimental: { | ||
dynamicIO: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |