-
Notifications
You must be signed in to change notification settings - Fork 27.4k
/
Copy pathstatic-shell-debugging.test.ts
60 lines (51 loc) · 1.74 KB
/
static-shell-debugging.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
50
51
52
53
54
55
56
57
58
59
60
import { nextTestSetup } from 'e2e-utils'
describe('static-shell-debugging', () => {
const ppr = Boolean(process.env.__NEXT_EXPERIMENTAL_PPR)
const context = {
ppr,
debugging: ppr,
}
const { next, skipped, isNextDev } = nextTestSetup({
files: __dirname,
// This test skips deployment because env vars that are doubled underscore prefixed
// are not supported. This is also intended to be used in development.
skipDeployment: true,
env: {
__NEXT_EXPERIMENTAL_STATIC_SHELL_DEBUGGING: context.debugging
? '1'
: undefined,
},
nextConfig: {
experimental: { ppr: context.ppr },
},
})
if (skipped) return
if (context.debugging && context.ppr) {
it('should only render the static shell', async () => {
const res = await next.fetch('/?__nextppronly=1')
expect(res.status).toBe(200)
const html = await res.text()
expect(html).toContain('Fallback')
expect(html).not.toContain('Dynamic')
})
// The __nextppronly query param is currently only supported in dev mode.
if (isNextDev) {
it('should skip hydration to avoid blanking out the page', async () => {
const browser = await next.browser('/?__nextppronly=1', {
waitHydration: false,
})
expect(await browser.elementByCss('div').text()).toBe('Fallback')
// Must not log the page error "Error: Connection closed."
expect(await browser.log()).toEqual([])
})
}
} else {
it('should render the full page', async () => {
const res = await next.fetch('/?__nextppronly=1')
expect(res.status).toBe(200)
const html = await res.text()
expect(html).toContain('Fallback')
expect(html).toContain('Dynamic')
})
}
})