Skip to content

Commit 6c63dba

Browse files
committed
test: tweak waitForHydration
1 parent 806abda commit 6c63dba

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/plugin-rsc/e2e/helper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ export const testNoJs = test.extend({
44
javaScriptEnabled: ({}, use) => use(false),
55
})
66

7-
export async function waitForHydration(page: Page) {
7+
export async function waitForHydration(page: Page, locator: string = 'body') {
88
await expect
99
.poll(
1010
() =>
1111
page
12-
.locator('body > *')
13-
.evaluateAll((elements) =>
14-
elements.some((el) =>
12+
.locator(locator)
13+
.evaluate(
14+
(el) =>
15+
el &&
1516
Object.keys(el).some((key) => key.startsWith('__reactFiber')),
16-
),
1717
),
1818
{ timeout: 3000 },
1919
)

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { expect, test } from '@playwright/test'
22
import { type Fixture, useFixture } from './fixture'
3-
import { expectNoReload, testNoJs, waitForHydration } from './helper'
3+
import {
4+
expectNoReload,
5+
testNoJs,
6+
waitForHydration as waitForHydration_,
7+
} from './helper'
48
import path from 'node:path'
59
import fs from 'node:fs'
610

@@ -39,6 +43,9 @@ test.describe('build-no-ssr', () => {
3943
})
4044

4145
function defineTest(f: Fixture, variant?: 'no-ssr') {
46+
const waitForHydration: typeof waitForHydration_ = (page) =>
47+
waitForHydration_(page, variant === 'no-ssr' ? '#root' : 'body')
48+
4249
test('basic', async ({ page }) => {
4350
await page.goto(f.url())
4451
await waitForHydration(page)

0 commit comments

Comments
 (0)