Skip to content

Commit 615c768

Browse files
authored
test: reduce ssr-vue playground flakiness (#11076)
1 parent e5a2e80 commit 615c768

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getColor,
1010
isBuild,
1111
page,
12+
untilBrowserLogAfter,
1213
untilUpdated,
1314
viteServer
1415
} from '~utils'
@@ -26,7 +27,8 @@ test('vuex can be import succeed by named import', async () => {
2627
})
2728

2829
test('/about', async () => {
29-
await page.goto(url + 'about')
30+
await untilBrowserLogAfter(() => page.goto(url + 'about'), 'hydrated')
31+
3032
expect(await page.textContent('h1')).toMatch('About')
3133
// should not have hydration mismatch
3234
browserLogs.forEach((msg) => {
@@ -54,7 +56,8 @@ test('/about', async () => {
5456
})
5557

5658
test('/external', async () => {
57-
await page.goto(url + 'external')
59+
await untilBrowserLogAfter(() => page.goto(url + 'external'), 'hydrated')
60+
5861
expect(await page.textContent('div')).toMatch(
5962
'Example external component content'
6063
)
@@ -81,7 +84,8 @@ test('/external', async () => {
8184
})
8285

8386
test('/', async () => {
84-
await page.goto(url)
87+
await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
88+
8589
expect(await page.textContent('h1')).toMatch('Home')
8690
// should not have hydration mismatch
8791
browserLogs.forEach((msg) => {
@@ -155,7 +159,8 @@ test('nested virtual module', async () => {
155159
})
156160

157161
test('hydration', async () => {
158-
await page.goto(url)
162+
await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
163+
159164
expect(await page.textContent('button')).toMatch('0')
160165
await page.click('button')
161166
expect(await page.textContent('button')).toMatch('1')
@@ -175,7 +180,8 @@ test(
175180
)
176181

177182
test('client navigation', async () => {
178-
await page.goto(url)
183+
await untilBrowserLogAfter(() => page.goto(url), 'hydrated')
184+
179185
await untilUpdated(() => page.textContent('a[href="/test/about"]'), 'About')
180186
await page.click('a[href="/test/about"]')
181187
await untilUpdated(() => page.textContent('h1'), 'About')

playground/ssr-vue/src/entry-client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ const { app, router } = createApp()
55
// wait until router is ready before mounting to ensure hydration match
66
router.isReady().then(() => {
77
app.mount('#app')
8+
9+
console.log('hydrated')
810
})

0 commit comments

Comments
 (0)