Skip to content

Commit 3c913a2

Browse files
authored
test: test SSR after HMR (#326)
1 parent 7e7322a commit 3c913a2

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

playground/ssr-react/__tests__/ssr-react.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { port } from './serve'
44
import {
55
browserLogs,
66
editFile,
7+
isBuild,
78
page,
89
untilBrowserLogAfter,
910
untilUpdated,
@@ -49,13 +50,18 @@ test('/', async () => {
4950
expect(html).toMatch('Home')
5051
})
5152

52-
test('hmr', async () => {
53+
test.skipIf(isBuild)('hmr', async () => {
5354
await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
5455

56+
await untilUpdated(() => page.textContent('h1'), 'Home')
5557
editFile('src/pages/Home.jsx', (code) =>
5658
code.replace('<h1>Home', '<h1>changed'),
5759
)
5860
await untilUpdated(() => page.textContent('h1'), 'changed')
61+
62+
// verify the change also affects next SSR
63+
const res = await page.reload()
64+
expect(await res?.text()).toContain('<h1>changed')
5965
})
6066

6167
test('client navigation', async () => {

playground/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"include": ["*.ts", "**/__test/*.ts", "**/vite.config.ts"],
2+
"include": ["*.ts", "**/__tests__/*.ts", "**/vite.config.ts"],
33
"exclude": ["**/dist/**"],
44
"compilerOptions": {
55
"target": "ES2020",

playground/vitest.config.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { resolve } from 'node:path'
22
import { defineConfig } from 'vitest/config'
33

4-
const timeout = process.env.CI ? 20_000 : 5_000
4+
const timeout = process.env.PWDEBUG ? Infinity : process.env.CI ? 20_000 : 5_000
55

66
export default defineConfig({
77
resolve: {

0 commit comments

Comments
 (0)