Skip to content

Commit e46db31

Browse files
committed
test: test hydration mistmatch
1 parent 614c780 commit e46db31

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/plugin-rsc/e2e/basic.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { type Fixture, setupIsolatedFixture, useFixture } from './fixture'
55
import { expectNoReload, testNoJs, waitForHydration } from './helper'
66

77
// TODO: parallel?
8+
// TODO: all tests don't need to be tested in all variants?
89

910
test.describe('dev-default', () => {
1011
const f = useFixture({ root: 'examples/basic', mode: 'dev' })
@@ -928,4 +929,27 @@ function defineTest(f: Fixture) {
928929
'(actionCount: 5, innerFnCount: 3)',
929930
)
930931
})
932+
933+
test('hydration mismatch', async ({ page }) => {
934+
const errors: Error[] = []
935+
page.on('pageerror', (error) => {
936+
errors.push(error)
937+
})
938+
await page.goto(f.url('/?test-hydration-mismatch'))
939+
await waitForHydration(page)
940+
expect(errors).toMatchObject([
941+
{
942+
message: expect.stringContaining(
943+
f.mode === 'dev'
944+
? `Hydration failed because the server rendered HTML didn't match the client.`
945+
: `Minified React error #418`,
946+
),
947+
},
948+
])
949+
950+
errors.length = 0
951+
await page.goto(f.url())
952+
await waitForHydration(page)
953+
expect(errors).toEqual([])
954+
})
931955
}

0 commit comments

Comments
 (0)