forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.test.js
37 lines (31 loc) · 1.1 KB
/
index.test.js
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
/* eslint-env jest */
import { findPort, killApp, nextBuild, nextStart } from 'next-test-utils'
import webdriver from 'next-webdriver'
import { join } from 'path'
const appDir = join(__dirname, '../')
let appPort
let server
jest.setTimeout(1000 * 60 * 2)
describe('hydrate/render ordering', () => {
beforeAll(async () => {
appPort = await findPort()
await nextBuild(appDir, [], {})
server = await nextStart(appDir, appPort)
})
afterAll(() => killApp(server))
it('correctly measures hydrate followed by render', async () => {
const browser = await webdriver(appPort, '/')
await browser.waitForElementByCss('#to-other')
await browser.elementByCss('#to-other').click()
await browser.waitForElementByCss('#on-other')
const beacons = (await browser.eval('window.__BEACONS'))
.map(([, value]) => Object.fromEntries(new URLSearchParams(value)))
.filter((p) => p.label === 'custom')
expect(beacons).toMatchObject([
{ name: 'Next.js-hydration' },
{ name: 'Next.js-render' },
{ name: 'Next.js-route-change-to-render' },
])
await browser.close()
})
})