hydrated
Wait until React has taken over (hydrated or rendered) the page's #app, its effects included: before that, clicks
do nothing, or nothing the app's (a link useAppLinks follows, whose handler an effect adds, loads the next page).
React is on the root as soon as it starts, and on what's in it once it has rendered it (not the scripts and styles
it puts first, which it leaves to the browser); its effects run after the next frame.
import type { Page } from "#codebase/tcmts/cli/test/browser"; export const hydrated = async (page: Page) => (await page.waitFor<boolean>( `(() => { const app = document.getElementById("app"); const has = (n, p) => !!n && Object.keys(n).some((k) => k.startsWith(p)); const first = [...(app?.children ?? [])].find((c) => !/^(SCRIPT|LINK|STYLE|META|TITLE)$/.test(c.tagName)); return has(app, "__reactContainer") && (!first || has(first, "__reactFiber")); })()`, (v) => !!v, )) && (await page.evaluate<boolean>( "new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(() => r(true)))))", ))
uses
used by
- tcmts.cli.test.e2e.examples.testNotesExample
- tcmts.cli.test.e2e.hub.testHubSignInAndStars
- tcmts.cli.test.e2e.prod.testAppUnderABase
- tcmts.cli.test.e2e.prod.testPagesShellsAreKept
- tcmts.cli.test.e2e.prod.testServerComponentsKeptAndRenderedAhead
- tcmts.cli.test.e2e.prod.testStaticSitesRenderEveryPage
- tcmts.cli.test.e2e.react.testComponentsAreCompiled
- tcmts.cli.test.e2e.react.testLazyChunksLoadWithThePage
- tcmts.cli.test.e2e.react.testPackageComponentsRenderInTheBrowser
- tcmts.cli.test.e2e.react.testPagesKeepAndRenderAhead
- tcmts.cli.test.e2e.react.testReactPlacementStreamingHydration
- tcmts.cli.test.e2e.react.testServerComponentsAreDebuggable
- tcmts.cli.test.e2e.react.testServerFunctionsAsProps