Open History to see the last commit
1import { expect, test } from '@playwright/test'
2
3test(`Next.js streams a DB result snapshot and hands off to browser sync`, async ({
4 page,
5 request,
6}) => {
7 const response = await request.get(`/`)
8 expect(response.ok()).toBe(true)
9 const html = await response.text()
10 expect(html).toContain(`Streamed from Next.js`)
11 expect(html).not.toContain(`NEXT_SOURCE_ONLY_DO_NOT_TRANSPORT`)
12
13 const browserErrors: Array<string> = []
14 page.on(`console`, (message) => {
15 if (message.type() === `error`) browserErrors.push(message.text())
16 })
17 page.on(`pageerror`, (error) => {
18 browserErrors.push(error.message)
19 })
20
21 await page.goto(`/`, { waitUntil: `commit` })
22
23 await expect(page.getByTestId(`stream-fallback`)).toBeVisible()
24 await expect(page.getByTestId(`streamed-todo-next-server-1`)).toHaveText(
25 `Streamed from Next.js`,
26 )
27 await expect(page.getByTestId(`stream-fallback`)).not.toBeVisible()
28 await expect(
29 page.getByTestId(`streamed-todo-next-server-1`),
30 ).not.toBeVisible()
31 await expect(page.getByTestId(`streamed-todo-next-browser-1`)).toHaveText(
32 `Reconciled by Next.js browser sync`,
33 )
34 expect(browserErrors).toEqual([])
35})