tests(start): update spa mode e2e to use production build #5284
main fromrefs/pull/5284/head·merged by nlynzaad(GitHub profile, opens in a new tab) This PR follows on #5262 and adds a custom server implementation to serve the spa mode production build for e2e tests on react-start-basic and solid-start-basic
Summary by CodeRabbit#
New Features
- SPA mode added with dedicated build/start workflows and paired servers to serve the SPA and proxy API/server requests on separate ports.
Tests
- Improved e2e reliability with explicit URL and network-idle waits; updated expectations to be SPA-aware (redirects, not-found, script presence).
Chores
- Added express and http-proxy-middleware dependencies; updated test/config setup to expose SPA-specific ports and enable SPA build/runtime options.
- 1
View your CI Pipeline Execution ↗ for commit 090b0c773c85cb2a0f21dd3d66d34adc3a64b16f
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 4m 21s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 15s View ↗
☁️ Nx Cloud last updated this comment at
2025-09-28 21:48:14UTCMore templates
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-static
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@5284@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5284@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5284@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5284@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5284@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5284@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5284@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5284@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5284@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5284@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5284@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5284@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5284@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5284@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5284@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5284@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5284@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5284@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5284@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5284@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5284@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5284@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5284@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5284@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5284@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5284@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5284@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5284@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5284@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5284@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5284@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5284@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5284@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5284commit:
090b0c7Actionable comments posted: 4
🧹 Nitpick comments (14)
e2e/react-start/basic/tests/not-found.spec.ts (1)
4-4: Align import path with local tests conventionUse a simpler relative path for consistency with other files under tests/.
-import { isSpaMode } from '../tests/utils/isSpaMode' +import { isSpaMode } from './utils/isSpaMode'e2e/react-start/basic/tests/redirect.spec.ts (2)
48-53: Avoid hardcoded localhost in request predicateBind to the current page origin to work in environments that resolve to 127.0.0.1 or custom hosts.
- const requestPromise = new Promise<void>((resolve) => { + const origin = new URL(page.url()).origin + const requestPromise = new Promise<void>((resolve) => { page.on('request', (request) => { - if ( - request.url().startsWith(`http://localhost:${PORT}/_serverFn/`) - ) { + if (request.url().startsWith(`${origin}/_serverFn/`)) { requestHappened = true resolve() } }) })
91-95: Wait for the redirect URL to settle to reduce flakinessDirect-visit flow can race; explicitly wait for the expected URL before asserting.
- const url = `http://localhost:${PORT}/posts` - - expect(page.url()).toBe(url) + const url = `http://localhost:${PORT}/posts` + await page.waitForURL(url) + expect(page.url()).toBe(url)e2e/react-start/basic/vite.config.ts (1)
5-5: Decouple build config from tests utilRead
process.env.MODEdirectly in the config to avoid importing from tests and reduce coupling.-import { isSpaMode } from './tests/utils/isSpaMode' +const isSpa = process.env.MODE === 'spa' @@ - tanstackStart({ - spa: isSpaMode ? spaModeConfiguration : undefined, - }), + tanstackStart({ + spa: isSpa ? spaModeConfiguration : undefined, + }),Also applies to: 24-25
e2e/solid-start/basic/vite.config.ts (1)
5-12: Optional: inline env check instead of importing from testsKeep config self-contained by reading
process.env.MODEhere.-import { isSpaMode } from './tests/utils/isSpaMode' +const isSpa = process.env.MODE === 'spa' @@ - tanstackStart({ - spa: isSpaMode ? spaModeConfiguration : undefined, - }), + tanstackStart({ + spa: isSpa ? spaModeConfiguration : undefined, + }),Also applies to: 22-25
e2e/solid-start/basic/package.json (1)
10-10: Cross‑platform env var for MODEOn Windows shells,
MODE=spawon’t work. Considercross-envfor portability.- "build:spa": "MODE=spa vite build && tsc --noEmit", + "build:spa": "cross-env MODE=spa vite build && tsc --noEmit"Add to devDependencies:
+ "cross-env": "^7.0.3"e2e/solid-start/basic/playwright.config.ts (2)
9-14: Ports/env look correct for SPA; consider scoping START_PORT to SPA onlyDeriving distinct PORT/START_PORT keys per mode is good. Minor: in non‑SPA runs START_PORT equals PORT and isn’t used—omit it from env when
!isSpaModeto reduce noise.webServer: { command: isSpaMode ? spaModeCommand : ssrModeCommand, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe', env: { MODE: process.env.MODE || '', VITE_NODE_ENV: 'test', VITE_EXTERNAL_PORT: String(EXTERNAL_PORT), VITE_SERVER_PORT: String(PORT), - START_PORT: String(START_PORT), + ...(isSpaMode ? { START_PORT: String(START_PORT) } : {}), PORT: String(PORT), }, },Also applies to: 48-48
20-20: Gate the config log behind a flagConsole noise can bloat Playwright output. Suggest logging only when
DEBUGorCIis set.-console.log('running in spa mode: ', isSpaMode.toString()) +if (process.env.DEBUG) console.log('running in spa mode:', isSpaMode)e2e/solid-start/basic/tests/navigation.spec.ts (1)
60-64: Assert page readiness before script globalsTo avoid evaluating globals before DOM is painted, mirror the client‑nav test by asserting the heading first.
await page.goto('/scripts') await page.waitForURL('/scripts') await page.waitForLoadState('networkidle') +await expect(page.getByTestId('scripts-test-heading')).toBeVisible() expect(await page.evaluate('window.SCRIPT_1')).toBe(true)e2e/react-start/basic/tests/navigation.spec.ts (2)
45-50: Mirror direct‑nav readiness checkAs in Solid, add a heading visibility assertion before reading script globals for deterministic timing.
await page.getByRole('link', { name: 'Scripts', exact: true }).click() await expect(page.getByTestId('scripts-test-heading')).toBeInViewport() expect(await page.evaluate('window.SCRIPT_1')).toBe(true) expect(await page.evaluate('window.SCRIPT_2')).toBe(undefined)And for direct navigation:
await page.goto('/scripts') await page.waitForURL('/scripts') await page.waitForLoadState('networkidle') +await expect(page.getByTestId('scripts-test-heading')).toBeVisible() expect(await page.evaluate('window.SCRIPT_1')).toBe(true) expect(await page.evaluate('window.SCRIPT_2')).toBe(undefined)Also applies to: 54-57
21-21: Consider adding the same initial wait in the first testFor consistency, add
await page.waitForURL('/')after the firstgoto('/')in “Navigating to post”.e2e/react-start/basic/server.js (3)
2-2: Harden file system paths (avoid CWD dependency in CI/Playwright)Relative paths to
./dist/...can break when the process CWD differs. Resolve from this file’s directory.Apply this diff:
import path from 'node:path' +import { fileURLToPath } from 'node:url' @@ -const startPort = process.env.START_PORT || 3001 +const startPort = process.env.START_PORT || 3001 + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) +const CLIENT_DIR = path.resolve(__dirname, 'dist/client') +const SERVER_ENTRY = path.resolve(__dirname, 'dist/server/server.js') @@ - const server = (await import('./dist/server/server.js')).default + const server = (await import(SERVER_ENTRY)).default @@ - app.use(express.static('./dist/client')) + app.use(express.static(CLIENT_DIR)) @@ - app.use(express.static('./dist/client')) + app.use(express.static(CLIENT_DIR)) @@ - res.sendFile(path.resolve('./dist/client/index.html')) + res.sendFile(path.join(CLIENT_DIR, 'index.html'))Also applies to: 11-11, 16-16, 48-49, 51-51
57-67: Reduce startup race: ensure Start server is listening before SPA proxies to itCurrently both servers start concurrently; the SPA may proxy to a port that isn’t listening yet. Start the Start server first, then the SPA.
Apply this diff (ESM with top‑level await):
-createSpaServer().then(async ({ app }) => - app.listen(port, () => { - console.info(`Client Server: http://localhost:${port}`) - }), -) - -createStartServer().then(async ({ app }) => - app.listen(startPort, () => { - console.info(`Start Server: http://localhost:${startPort}`) - }), -) +const start = await createStartServer() +await new Promise((resolve) => + start.app.listen(startPort, () => { + console.info(`Start Server: http://localhost:${startPort}`) + resolve() + }), +) +const spa = await createSpaServer() +spa.app.listen(port, () => { + console.info(`Client Server: http://localhost:${port}`) +})
14-15: Minor hardening: hide Express fingerprintDisable the
X-Powered-Byheader.Apply this diff:
const app = express() + app.disable('x-powered-by') @@ const app = express() + app.disable('x-powered-by')Also applies to: 30-31
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between d363dca4617d448f4e86efaf4c93a4ac99d94953 and 42b217aaadb446a8d2cbca12cb737bea190c6e96.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (16)
e2e/react-start/basic/package.json(2 hunks)e2e/react-start/basic/playwright.config.ts(2 hunks)e2e/react-start/basic/server.js(1 hunks)e2e/react-start/basic/tests/navigation.spec.ts(3 hunks)e2e/react-start/basic/tests/not-found.spec.ts(3 hunks)e2e/react-start/basic/tests/redirect.spec.ts(1 hunks)e2e/react-start/basic/tests/search-params.spec.ts(1 hunks)e2e/react-start/basic/vite.config.ts(1 hunks)e2e/solid-start/basic/package.json(2 hunks)e2e/solid-start/basic/playwright.config.ts(2 hunks)e2e/solid-start/basic/server.js(1 hunks)e2e/solid-start/basic/tests/navigation.spec.ts(5 hunks)e2e/solid-start/basic/tests/not-found.spec.ts(2 hunks)e2e/solid-start/basic/tests/redirect.spec.ts(1 hunks)e2e/solid-start/basic/tests/search-params.spec.ts(3 hunks)e2e/solid-start/basic/vite.config.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
e2e/react-start/basic/tests/not-found.spec.tse2e/solid-start/basic/tests/redirect.spec.tse2e/react-start/basic/tests/search-params.spec.tse2e/react-start/basic/tests/redirect.spec.tse2e/solid-start/basic/tests/search-params.spec.tse2e/solid-start/basic/tests/not-found.spec.tse2e/react-start/basic/tests/navigation.spec.tse2e/solid-start/basic/vite.config.tse2e/solid-start/basic/tests/navigation.spec.tse2e/react-start/basic/playwright.config.tse2e/react-start/basic/vite.config.tse2e/solid-start/basic/playwright.config.ts
e2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Store end-to-end tests under the e2e/ directory
Files:
e2e/react-start/basic/tests/not-found.spec.tse2e/solid-start/basic/tests/redirect.spec.tse2e/react-start/basic/tests/search-params.spec.tse2e/react-start/basic/tests/redirect.spec.tse2e/solid-start/basic/tests/search-params.spec.tse2e/solid-start/basic/tests/not-found.spec.tse2e/solid-start/basic/package.jsone2e/solid-start/basic/server.jse2e/react-start/basic/package.jsone2e/react-start/basic/tests/navigation.spec.tse2e/solid-start/basic/vite.config.tse2e/solid-start/basic/tests/navigation.spec.tse2e/react-start/basic/server.jse2e/react-start/basic/playwright.config.tse2e/react-start/basic/vite.config.tse2e/solid-start/basic/playwright.config.ts
**/package.json
📄 CodeRabbit inference engine (AGENTS.md)
Use workspace:* protocol for internal dependencies in package.json files
Files:
e2e/solid-start/basic/package.jsone2e/react-start/basic/package.json
🧬 Code graph analysis (7)
e2e/solid-start/basic/tests/redirect.spec.ts (3)
e2e/react-start/server-functions/playwright.config.ts (1)
PORT(5-5)
e2e/solid-start/server-functions/playwright.config.ts (1)
PORT(5-5)
e2e/e2e-utils/src/derivePort.ts (1)
getTestServerPort(25-27)
e2e/react-start/basic/tests/search-params.spec.ts (1)
e2e/react-start/basic/tests/utils/isSpaMode.ts (1)
isSpaMode(1-1)
e2e/react-start/basic/tests/redirect.spec.ts (2)
e2e/e2e-utils/src/derivePort.ts (1)
getTestServerPort(25-27)
e2e/react-start/basic/tests/utils/isSpaMode.ts (1)
isSpaMode(1-1)
e2e/solid-start/basic/server.js (1)
e2e/react-start/basic/server.js (8)
port(6-6)startPort(8-8)createStartServer(10-27)server(11-11)nodeHandler(12-12)app(14-14)app(30-30)createSpaServer(29-55)
e2e/react-start/basic/playwright.config.ts (5)
e2e/react-start/server-functions/playwright.config.ts (1)
PORT(5-5)
e2e/solid-start/server-functions/playwright.config.ts (1)
PORT(5-5)
e2e/e2e-utils/src/derivePort.ts (2)
getTestServerPort(25-27)getDummyServerPort(21-23)
e2e/solid-start/basic/tests/utils/isSpaMode.ts (1)
isSpaMode(1-1)
e2e/react-start/basic/tests/utils/isSpaMode.ts (1)
isSpaMode(1-1)
e2e/react-start/basic/vite.config.ts (1)
e2e/react-start/basic/tests/utils/isSpaMode.ts (1)
isSpaMode(1-1)
e2e/solid-start/basic/playwright.config.ts (2)
e2e/e2e-utils/src/derivePort.ts (2)
getTestServerPort(25-27)getDummyServerPort(21-23)
e2e/solid-start/basic/tests/utils/isSpaMode.ts (1)
isSpaMode(1-1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (28)
e2e/react-start/basic/package.json (3)
10-10: LGTM! SPA build script follows the pattern.The build:spa script correctly sets MODE=spa and follows the existing build process.
12-12: LGTM! SPA start script references the custom server.The start:spa script correctly points to the custom server implementation.
21-22: Dependencies are secure and appropriately versioned.Both express@5.1.0 and http-proxy-middleware@3.0.5 are secure versions. The http-proxy-middleware version includes fixes for CVE-2025-32997 and CVE-2024-21536.
As per coding guidelines
e2e/solid-start/basic/tests/redirect.spec.ts (2)
10-10: LGTM! Consistent import pattern across test files.The import follows the established pattern for accessing SPA mode state in tests.
15-17: LGTM! SPA-aware port selection ensures correct test server.The conditional port naming ensures tests connect to the appropriate server instance (SPA vs SSR).
e2e/solid-start/basic/tests/not-found.spec.ts (2)
4-4: LGTM! Consistent import pattern.The import follows the established pattern for accessing SPA mode state.
18-18: LGTM! Correct status code handling for SPA vs SSR modes.In SPA mode, the server returns 200 for all routes since client-side routing handles not-found scenarios. This is the expected behavioral difference.
e2e/react-start/basic/tests/search-params.spec.ts (2)
30-32: LGTM! Correct handling of SPA mode redirect behavior.In SPA mode, redirects are handled client-side, so server redirect responses won't occur. The conditional logic correctly skips these assertions for SPA tests.
55-57: LGTM! Consistent redirect handling pattern.The conditional logic maintains consistency with the redirect behavior handling for SPA mode.
e2e/solid-start/basic/tests/search-params.spec.ts (2)
3-3: LGTM! Consistent import pattern.The import follows the established pattern for accessing SPA mode state in tests.
29-31: LGTM! Appropriate conditional logic for SPA mode.The conditional logic correctly handles the behavioral difference between SPA and SSR modes. In SPA mode, redirects are handled client-side, so server redirect responses won't occur.
Also applies to: 53-55
e2e/react-start/basic/tests/not-found.spec.ts (1)
18-18: Good: not-found status accounts for SPA fallback200 vs 404 based on SPA mode mirrors real server behavior. LGTM.
e2e/react-start/basic/tests/redirect.spec.ts (2)
15-17: LGTM: spa-aware PORT avoids collisions across modesSuffixing the derive key with _spa yields a distinct port. Nice.
10-10: Type check for JSON import assertionEnsure tsconfig for these tests has
resolveJsonModule: trueand a compatible module resolution (e.g.,"moduleResolution": "bundler"or"nodeNext") sowith { type: 'json' }compiles cleanly under tsc.Would you confirm tsconfig settings for the e2e React Start project?
e2e/react-start/basic/vite.config.ts (1)
24-25: LGTM: SPA wiring into tanstackStartPassing spa configuration via isSpaMode is correct.
e2e/solid-start/basic/vite.config.ts (1)
22-26: LGTM: SPA mode correctly plumbed into Solid Start pluginConfiguration matches the intended SPA build behavior.
e2e/solid-start/basic/package.json (2)
18-27: Deps look appropriate for SPA proxy serverexpress@^5 and http-proxy-middleware@^3 are suitable for the custom SPA server. No further changes.
12-12: server.js already uses ESM imports—no changes required All imports useimportsyntax and norequire()calls were found.e2e/solid-start/basic/tests/navigation.spec.ts (2)
12-13: Good stability improvements with URL/load waitsThe added
waitForURL/networkidlepoints should reduce flakiness across SPA/SSR.Also applies to: 23-24, 33-34, 50-55, 60-64, 69-70, 79-80
54-55: No change needed—SSR omitsscript2.js, sowindow.SCRIPT_2beingundefinedis correct Inscripts.tsx,isProdistrueduring the production build that SSR uses, causing theisProd ? undefined : { src: 'script2.js' }branch to dropscript2.jsentirely. Hence in SSR modewindow.SCRIPT_2is undefined as the tests assert.e2e/react-start/basic/playwright.config.ts (2)
9-14: Ports/env wiring LGTMDistinct PORT/START_PORT derivation and env exposure look good for SPA orchestration.
Also applies to: 47-48
17-17: Confirmed SPA scripts existe2e/react-start/basic/tests/navigation.spec.ts (2)
21-21: Stability waits look goodThe added
waitForURLandnetworkidlesyncs should reduce flakes across runs.Also applies to: 29-29, 45-45, 54-55, 57-57, 62-62, 71-71
49-50: Sanity-check SSR mode Confirm that your SSR setup does not includepublic/script2.js(sowindow.SCRIPT_2remains undefined).e2e/solid-start/basic/server.js (2)
32-46: Proxy targets/path joiningUsing
app.use('/api', proxy({ target: http://localhost:${startPort}/api }))is valid in Express (mount strips/api). No change required; just noting the intent is correct.
1-1: Import path correct: All e2e examples importtoNodeHandlerfrom'srvx/node'consistently; no change required.Likely an incorrect or invalid review comment.
e2e/solid-start/basic/playwright.config.ts (1)
17-17: Scripts and port bindings are correctly definedbuild:spaandstart:spaare present in package.json, and Playwright’swebServerenv passesPORTandSTART_PORTintoserver.js, which listens on both ports.e2e/react-start/basic/server.js (1)
1-1: VerifytoNodeHandlerimport path Ensure your installedsrvxversion actually exportstoNodeHandlerfromsrvx/node(e.g. check itspackage.json > exportsor inspect the package files). If that subpath isn’t available, switch to the known adapter invinxi/http:-import { toNodeHandler } from 'srvx/node' +import { toNodeHandler } from 'vinxi/http'@@ -6 +6 @@66 import { isSpaMode } from 'tests/utils/isSpaMode'⚠️ Potential issue | 🟠 Major
Import path likely needs to be relative
tests/utils/isSpaModedepends on path mapping; other suites use a relative path. Use a relative import for portability.-import { isSpaMode } from 'tests/utils/isSpaMode' +import { isSpaMode } from './tests/utils/isSpaMode'📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import { isSpaMode } from './tests/utils/isSpaMode'🤖 Prompt for AI Agents
In e2e/react-start/basic/playwright.config.ts around line 6, the import currently uses a mapped module path 'tests/utils/isSpaMode' which may fail outside this repo configuration; change it to a relative path (e.g., '../../tests/utils/isSpaMode' or the correct relative path from this file) so the import resolves without path mapping—update the import statement to the correct relative relative filepath and verify the file exists at that location.@@ -0,0 +18,21 @@18+ app.use(async (req, res, next) => {19+ try {20+ await nodeHandler(req, res)21+ } catch (error) {22+ next(error)23+ }24+ })25+26+ return { app }27+}28+29+export async function createSpaServer() {30+ const app = express()31+32+ app.use(33+ '/api',34+ createProxyMiddleware({35+ target: `http://localhost:${startPort}/api`, // Replace with your target server's URL36+ changeOrigin: false, // Needed for virtual hosted sites,37+ }),38+ )⚠️ Potential issue | 🔴 Critical
Fix proxy targets to avoid path duplication (/api → /api/api) and enable proper Host forwarding
With
context='/api'andtarget='.../api', a request like/api/foobecomeshttp://localhost:<START_PORT>/api/api/foo. Same for/_serverFn. Pointtargetto the origin only and setchangeOrigin: true.Apply this diff:
@@ app.use( '/api', createProxyMiddleware({ - target: `http://localhost:${startPort}/api`, // Replace with your target server's URL - changeOrigin: false, // Needed for virtual hosted sites, + target: `http://127.0.0.1:${startPort}`, + changeOrigin: true, }), ) @@ app.use( '/_serverFn', createProxyMiddleware({ - target: `http://localhost:${startPort}/_serverFn`, // Replace with your target server's URL - changeOrigin: false, // Needed for virtual hosted sites, + target: `http://127.0.0.1:${startPort}`, + changeOrigin: true, }), )Also applies to: 41-46
🤖 Prompt for AI Agents
In e2e/react-start/basic/server.js around lines 33-38 (and similarly 41-46), the proxy targets include the path (e.g. target:`http://localhost:${startPort}/api`) which duplicates the context and causes requests like /api/foo to be forwarded to /api/api/foo; update the target to the origin only (e.g. `http://localhost:${startPort}`) and set changeOrigin: true so the Host header is forwarded correctly; apply the same change to the /_serverFn proxy to remove the duplicate path and enable proper host forwarding.irrelevant to the tests
@nlynzaad I understand that for your current test scenarios, the proxy path duplication may not be causing any failures. You're right that if the tests are passing as expected, this configuration issue doesn't block the immediate testing objectives.
The technical concern about path duplication (
/api/foo→/api/api/foo) would typically cause routing issues, but if your test setup is working correctly with the current configuration, then it's serving its purpose for the e2e testing goals of this PR.@@ -0,0 +32,21 @@32+ app.use(33+ '/api',34+ createProxyMiddleware({35+ target: `http://localhost:${startPort}/api`, // Replace with your target server's URL36+ changeOrigin: false, // Needed for virtual hosted sites,37+ }),38+ )39+40+ app.use(41+ '/_serverFn',42+ createProxyMiddleware({43+ target: `http://localhost:${startPort}/_serverFn`, // Replace with your target server's URL44+ changeOrigin: false, // Needed for virtual hosted sites,45+ }),46+ )47+48+ app.use(express.static('./dist/client'))49+50+ app.get('/{*splat}', (req, res) => {51+ res.sendFile(path.resolve('./dist/client/index.html'))52+ })⚠️ Potential issue | 🔴 Critical
Express catch‑all path is invalid; use '*'
'/{*splat}'doesn't match all routes in Express. Use a wildcard.Apply this diff:
- app.get('/{*splat}', (req, res) => { - res.sendFile(path.resolve('./dist/client/index.html')) - }) + app.get('*', (_req, res) => { + res.sendFile(path.resolve('./dist/client/index.html')) + })📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
app.get('*', (_req, res) => { res.sendFile(path.resolve('./dist/client/index.html')) })🤖 Prompt for AI Agents
In e2e/react-start/basic/server.js around lines 50 to 52, the Express route uses an invalid pattern '/{*splat}'; replace it with a proper wildcard such as '*' (i.e., app.get('*', (req, res) => { res.sendFile(path.resolve('./dist/client/index.html')) })) so the catch‑all correctly matches all routes.express v 5 requires new splat format. /{*splat}
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Check what version of Express is being used in the package.json cat e2e/react-start/basic/package.json | jq '.dependencies.express'Length of output: 8
🌐 Web query:
Express v5 catch-all route syntax wildcard parameter naming💡 Result:
In Express v5 unnamed wildcards (e.g. "/*") are not allowed — you must give the wildcard a name. Use either:
- Match everything except the root path: app.all('/*splat', (req, res) => { // matched path in req.params.splat });
- Match including root (/): app.all('/{*splat}', (req, res) => { // matched path (possibly empty for "/") in req.params.splat });
The named wildcard behaves like a route parameter (accessible as req.params.). See the Express v5 migration notes. [1][2]
Sources: [1] Express — Migrating to v5 (Path route matching syntax). [2] GitHub issue discussion / examples showing the required named wildcard.
@nlynzaad You're absolutely correct! Thank you for the correction.
In Express v5, unnamed wildcards (e.g. "/") are not allowed — you must give the wildcard a name. For matching including the root path, the correct syntax is `/{splat}`, which is exactly what you've implemented.
I can see from the package.json that this project is using Express "^5.1.0", so the
/{*splat}syntax is indeed required. My suggestion to use*would have caused a "Missing parameter name" error in Express v5.Your implementation is correct for a SPA catch-all route that needs to handle both the root path and all other routes. I apologize for the confusion in my initial review.
✏️ Learnings added
Learnt from: nlynzaad PR: TanStack/router#5284 File: e2e/react-start/basic/server.js:50-0 Timestamp: 2025-09-28T21:41:45.205Z Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
@@ -0,0 +32,21 @@32+ app.use(33+ '/api',34+ createProxyMiddleware({35+ target: `http://localhost:${startPort}/api`, // Replace with your target server's URL36+ changeOrigin: false, // Needed for virtual hosted sites,37+ }),38+ )39+40+ app.use(41+ '/_serverFn',42+ createProxyMiddleware({43+ target: `http://localhost:${startPort}/_serverFn`, // Replace with your target server's URL44+ changeOrigin: false, // Needed for virtual hosted sites,45+ }),46+ )47+48+ app.use(express.static('./dist/client'))49+50+ app.get('/{*splat}', (req, res) => {51+ res.sendFile(path.resolve('./dist/client/index.html'))52+ })⚠️ Potential issue | 🔴 Critical
Express wildcard route is incorrect; fallback won’t match
'/{*splat}'isn’t valid Express syntax. Use a catch‑all so client routing works.- app.get('/{*splat}', (req, res) => { + // Fallback to index.html for all other GETs (after proxies & static) + app.get('*', (req, res) => { res.sendFile(path.resolve('./dist/client/index.html')) })If you need to exclude
/apiand/_serverFndefensively:- app.get('*', (req, res) => { + app.get(/^\/(?!api\/|_serverFn\/).*/, (req, res) => { res.sendFile(path.resolve('./dist/client/index.html')) })📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// Fallback to index.html for all other GETs (after proxies & static) app.get('*', (req, res) => { res.sendFile(path.resolve('./dist/client/index.html')) })🤖 Prompt for AI Agents
e2e/solid-start/basic/server.js around lines 50-52: the Express route string '/{*splat}' is not valid so the fallback won't match; replace it with a proper catch‑all (e.g. use app.get('*', (req, res) => { ... }) ) so client-side routing works, and if you need to defensively exclude /api and /_serverFn either mount those routes before the catch‑all or use a negative-regex route (e.g. app.get(/^(?!\/(?:api|_serverFn)).*/, ...) ) to serve index.html only for non-API requests; keep the same res.sendFile call with path.resolve('./dist/client/index.html').nlynzaad(GitHub profile, opens in a new tab)replied on
e2e/react-start/basic/server.jslines 50 to 52express v 5 requires new splat format. /{*splat}
nlynzaad(GitHub profile, opens in a new tab)replied on
e2e/react-start/basic/server.jslines 33 to 38irrelevant to the tests
coderabbitai[bot](GitHub profile, opens in a new tab)replied on
e2e/react-start/basic/server.jslines 33 to 38@nlynzaad I understand that for your current test scenarios, the proxy path duplication may not be causing any failures. You're right that if the tests are passing as expected, this configuration issue doesn't block the immediate testing objectives.
The technical concern about path duplication (
/api/foo→/api/api/foo) would typically cause routing issues, but if your test setup is working correctly with the current configuration, then it's serving its purpose for the e2e testing goals of this PR.coderabbitai[bot](GitHub profile, opens in a new tab)replied on
e2e/react-start/basic/server.jslines 50 to 52🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Check what version of Express is being used in the package.json cat e2e/react-start/basic/package.json | jq '.dependencies.express'Length of output: 8
🌐 Web query:
Express v5 catch-all route syntax wildcard parameter naming💡 Result:
In Express v5 unnamed wildcards (e.g. "/*") are not allowed — you must give the wildcard a name. Use either:
- Match everything except the root path: app.all('/*splat', (req, res) => { // matched path in req.params.splat });
- Match including root (/): app.all('/{*splat}', (req, res) => { // matched path (possibly empty for "/") in req.params.splat });
The named wildcard behaves like a route parameter (accessible as req.params.). See the Express v5 migration notes. [1][2]
Sources: [1] Express — Migrating to v5 (Path route matching syntax). [2] GitHub issue discussion / examples showing the required named wildcard.
@nlynzaad You're absolutely correct! Thank you for the correction.
In Express v5, unnamed wildcards (e.g. "/") are not allowed — you must give the wildcard a name. For matching including the root path, the correct syntax is `/{splat}`, which is exactly what you've implemented.
I can see from the package.json that this project is using Express "^5.1.0", so the
/{*splat}syntax is indeed required. My suggestion to use*would have caused a "Missing parameter name" error in Express v5.Your implementation is correct for a SPA catch-all route that needs to handle both the root path and all other routes. I apologize for the confusion in my initial review.
✏️ Learnings added
Learnt from: nlynzaad PR: TanStack/router#5284 File: e2e/react-start/basic/server.js:50-0 Timestamp: 2025-09-28T21:41:45.205Z Learning: In Express v5, catch-all routes must use named wildcards. Use `/*splat` to match everything except root path, or `/{*splat}` (with braces) to match including root path. The old `*` syntax is not allowed and will cause "Missing parameter name" errors. This breaking change requires explicit naming of wildcard parameters.Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
nlynzaad(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Walkthrough#
Adds SPA-mode workflows to e2e React and Solid start examples: new Express-based servers with proxying, SPA build/start scripts and dependencies, Playwright config updates with START_PORT/env, Vite SPA configuration changes, and test adjustments (URL waits, conditional expectations) across navigation, not-found, redirect, and search-params specs.
Changes#
e2e/react-start/basic/package.json,e2e/solid-start/basic/package.jsonbuild:spaandstart:spascripts; addexpressandhttp-proxy-middlewaredependencies.e2e/react-start/basic/playwright.config.ts,e2e/solid-start/basic/playwright.config.tsSTART_PORT(SPA-aware suffix), updatePORTnaming for SPA, addSTART_PORTtowebServer.env, and switch SPA command tobuild:spa+start:spa(Solid adds a spa-mode console log).e2e/react-start/basic/server.js,e2e/solid-start/basic/server.jscreateStartServer()andcreateSpaServer(). Start server loads dist/server and wraps fetch viatoNodeHandler; SPA server (Express) servesdist/client, proxies/apiand/_serverFnto the start server, and servesindex.htmlfor client routes. Both servers launched onPORTandSTART_PORT.e2e/react-start/basic/tests/navigation.spec.ts,e2e/solid-start/basic/tests/navigation.spec.tswaitForURLsteps and network-idle waits to stabilize navigation; removeisSpaMode-based conditional forSCRIPT_2(now alwaysundefined).e2e/react-start/basic/tests/not-found.spec.ts,e2e/solid-start/basic/tests/not-found.spec.tsisSpaMode; adjust not-found expectations to200when SPA mode, else404.e2e/react-start/basic/tests/redirect.spec.ts,e2e/solid-start/basic/tests/redirect.spec.tsPORT; remove SPA-specific error-whitelist block (React); minor whitespace tweaks.e2e/react-start/basic/tests/search-params.spec.ts,e2e/solid-start/basic/tests/search-params.spec.tsif (!isSpaMode)guards).e2e/react-start/basic/vite.config.ts,e2e/solid-start/basic/vite.config.tsisSpaModeinline. Solid: addspaoption totanstackStart({ spa: ... }), importisSpaMode, and include TS-ignore for hidden option.Sequence Diagram(s)#
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested labels#
package: react-start,package: solid-startSuggested reviewers#
Poem#
Pre-merge checks and finishing touches#
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 42b217aaadb446a8d2cbca12cb737bea190c6e96 and 090b0c773c85cb2a0f21dd3d66d34adc3a64b16f.
📒 Files selected for processing (1)
e2e/react-start/basic/playwright.config.ts(2 hunks)🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
e2e/react-start/basic/playwright.config.tse2e/**
📄 CodeRabbit inference engine (AGENTS.md)
Files:
e2e/react-start/basic/playwright.config.ts🧬 Code graph analysis (1)
e2e/react-start/basic/playwright.config.ts (4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment `@coderabbitai help` to get the list of available commands and usage tips.