From 97e69f3987865a6776a0f9d01c3de6b9e2782ab2 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 8 Oct 2026 11:30:49 +0800 Subject: [PATCH] Wait for the TanStack Start page before the dev server tests run Another test file can bind the port that getPort() released before the dev server starts. The readiness check accepted any HTTP reply, so the tests ran against that server. Require the app page, fail fast when the dev server exits, and pass --strictPort so a taken port is reported instead of moved. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../void/test/integration/tanstack-start.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/void/test/integration/tanstack-start.test.ts b/packages/void/test/integration/tanstack-start.test.ts index 3acecaf82..7984e5700 100644 --- a/packages/void/test/integration/tanstack-start.test.ts +++ b/packages/void/test/integration/tanstack-start.test.ts @@ -1,7 +1,12 @@ import { join } from 'node:path'; import spawn from 'cross-spawn'; import { afterAll, beforeAll, describe, expect, it } from 'vite-plus/test'; -import { getPort, waitForServer, killChild } from '../../../../test/integration-helpers.ts'; +import { + collectServerOutput, + getPort, + killChild, + waitForServer, +} from '../../../../test/integration-helpers.ts'; const ROOT = join(import.meta.dirname, '..', '..', '..', '..'); const PLAYGROUND = 'playground/tanstack-start'; @@ -27,6 +32,7 @@ describe('playground/tanstack-start dev', () => { '127.0.0.1', '--port', String(DEV_PORT), + '--strictPort', ], { cwd: ROOT, @@ -42,7 +48,13 @@ describe('playground/tanstack-start dev', () => { stderr += String(chunk); }); - await waitForServer(DEV_BASE, 20_000); + // Other test files in the same run can bind the port getPort() released, + // so only this app's page counts as ready. + await waitForServer(DEV_BASE, 20_000, { + expectBody: 'TanStack Start + Void', + isAlive: () => child.exitCode === null && child.signalCode === null, + diagnostics: collectServerOutput(child), + }); }); afterAll(async () => {