diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts b/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts
index 39feb3b138..93844e1a28 100644
--- a/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts
+++ b/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts
@@ -1,61 +1,55 @@
import { describe, expect, test } from 'vitest'
-import {
- compileCode,
- evaluateModule,
- importSources,
-} from '../regression-helpers'
-import { getModuleErrors } from '@tanstack/compiler-test-utils/validate-module'
+import { renderServer, renderSource } from '../regression-helpers'
+import type { ModuleStub, Render } from '../regression-helpers'
// On the server, `` (of a TanStack router package) renders its
-// fallback: its children are gone from the SSR output, so the server never
-// evaluates them (the evaluated JSX runtime calls components and props
-// eagerly; on the server, the libraries the children use throw when
-// called). Whether the SSR output keeps their imports is left open (neutral
-// names, user ruling 2026-10-17). The client keeps them. Other components
+// fallback: the server output drops its children, so the server never
+// evaluates them (on the server, the libraries the children use throw when
+// called, here even while the children's elements are created). Rendered
+// with the real React and the real `ClientOnly` of `@tanstack/react-router`
+// (which renders its fallback whenever it renders on a server), the server
+// output renders what the uncompiled source renders there. Whether the SSR
+// output keeps the children's imports is left open (neutral names, user
+// ruling 2026-10-17). The client keeps the children: it renders them once
+// the page hydrated (integration/clientOnlyJSX.test.ts). Other components
// named ClientOnly are left alone.
// N4 (replaces the former snapshot fixtures of this directory).
describe(' children', () => {
- const libraries = {
- 'heavy-chart-library': { Chart: () => '' },
+ /** The libraries the fixtures import (plain text components). */
+ const libraries: Record> = {
+ 'heavy-chart-library': { Chart: () => 'chart' },
'./utils': { formatData: () => 'data' },
- 'video-player-lib': { VideoPlayer: () => '
}`),
- ).toBe('[
module
]')
+ ).toContain('
module
')
})
// Source: Qwik optimizer should_not_auto_export_var_shadowed_in_catch
@@ -152,7 +167,7 @@ test('client: the children read a catch parameter', async () => {
return
')
+ // The client output alone.
+ calls = 0
+ await renderClient(`${head}${code}`)
expect(calls).toBe(1)
},
)
@@ -218,9 +237,8 @@ export function Page() {
// Source: Qwik optimizer local_shadowing_destructured_prop,
// should_not_auto_export_var_shadowed_in_catch
test('client: names the children declare themselves shadow the locals of the component', async () => {
- expect(
- await renderPage(
- `export function Page({ value }) {
+ const html = await renderPage(
+ `export function Page({ value }) {
const x = 'outer'
console.log(x)
return
@@ -228,11 +246,9 @@ test('client: names the children declare themselves shadow the locals of the com
{(() => { try { throw new Error('e') } catch (err) { const x = 'catch:' + err.message; return x } })()}
X!')
})
// Split children move to another module, so only runtime values may reach
@@ -267,7 +283,7 @@ export function Page({ v }: { v: unknown }) {
}`,
{ v: 'x' },
),
- ).toBe('[
1
xx
]')
+ ).toContain('
1
xx
')
})
describe('names the compiler generates', () => {
@@ -308,23 +324,23 @@ export function Page() {
for (const name of globals) {
;(globalThis as Record)[name] = `global:${name}`
}
- const { module, lazyChunks } = await loadClientModule(
+ const { client } = await expectRendersLikeSource(
`export const before = [${globals.join(', ')}]
${page(`['child']`)}`,
)
- expect(module.before).toEqual(globals.map((name) => `global:${name}`))
- expect(module.Page()).toBe(
- '[
]]',
+}`,
+ { props: { isOpen: true, fee: 5 } },
)
- // The nested boundary rendered through its own chunk.
- expect(lazyChunks.map((chunk) => chunk.rendered)).toEqual([true, true])
+ expect(client.html).toContain('
fee:5
')
})
+// The local is not named `key`: React keeps a `key` prop for itself (pinned
+// in known-bugs-hydrate.test.ts).
// Source: hydrate-when-transform.test.ts "captures identifiers used by
// shorthand objects and computed members"
test('client: the children read locals through a shorthand property and a computed member', async () => {
expect(
await renderPage(`import { visible } from '@tanstack/react-start/hydration'
export function Page() {
- const key = 'name'
+ const field = 'name'
const items = { name: 'Ada' }
return (
-
+
)
}
-function Widget(props: { data: { key: string; value: string } }) {
- return
')
})
// Like `style={{ color: color }}`.
@@ -415,11 +439,11 @@ test('client: the children read locals through a property value and a computed m
expect(
await renderPage(`export function Page() {
const label = 'Ada'
- const key = 'name'
+ const field = 'name'
const items = { name: 'Lovelace' }
- return
{({ text: label }).text}{items[key]}
+ return
{({ text: label }).text + items[field]}
}`),
- ).toBe('[
AdaLovelace
]')
+ ).toContain('
AdaLovelace
')
})
// Optional members, method keys and other property names are pinned in
@@ -428,14 +452,14 @@ test('client: member names and object keys are no reads of a local declared late
expect(
await renderPage(
`export function Page({ obj }) {
- const el =
{obj.later}{({ later: '!' }).later}
+ const el =
{obj.later + ({ later: '!' }).later}
const later = 1
console.log(later)
return el
}`,
{ obj: { later: 'L' } },
),
- ).toBe('[
L!
]')
+ ).toContain('
L!
')
})
describe('globals', () => {
@@ -445,15 +469,16 @@ describe('globals', () => {
})
test('client: a boundary spreading a global splits children rendering a global component', async () => {
+ const { load } = await startPackage('@tanstack/react-start/hydration')
Object.assign(globalThis, {
- GlobalWidget: () => '',
- hydrateDefaults: { when: 'idle' },
+ GlobalWidget: () => 'global-widget',
+ hydrateDefaults: { when: load() },
})
expect(
await renderPage(`export function Page() {
return
}`),
- ).toBe('[]')
+ ).toContain('global-widget')
})
})
@@ -464,10 +489,10 @@ test('client: the children render a local component and read a local value', asy
await renderPage(
`export function Page({ name }) {
const count = 1
- const Local = (props) => {name}{props.count === count ? '' : '!'}
+ const Local = (props) => {name + (props.count === count ? '' : '!')}
return {name}
}`,
{ name: 'n' },
),
- ).toBe('[nn]')
+ ).toContain('nn')
})