-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
Copy pathdynamic-error.test.ts
49 lines (44 loc) · 1.43 KB
/
dynamic-error.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-env jest */
import { createSandbox } from 'development-sandbox'
import { FileRef, nextTestSetup } from 'e2e-utils'
import path from 'path'
import { outdent } from 'outdent'
describe('dynamic = "error" in devmode', () => {
const { next } = nextTestSetup({
files: new FileRef(path.join(__dirname, 'fixtures', 'default-template')),
})
it('should show error overlay when dynamic is forced', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'app/server/page.js',
outdent`
import { cookies } from 'next/headers';
export default async function Page() {
await cookies()
return null
}
export const dynamic = "error"
`,
],
]),
'/server'
)
const { browser } = sandbox
await expect(browser).toDisplayRedbox(`
{
"count": 1,
"description": "Error: Route /server with \`dynamic = "error"\` couldn't be rendered statically because it used \`cookies\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
"environmentLabel": "Server",
"label": "Unhandled Runtime Error",
"source": "app/server/page.js (4:16) @ Page
> 4 | await cookies()
| ^",
"stack": [
"Page app/server/page.js (4:16)",
],
}
`)
})
})