Skip to content

Commit f87e02b

Browse files
djgouldclaude
andcommitted
test(tanstack-react-start): assert missing-key error from dev server stderr
TanStack Start answers an unhandled middleware error with an opaque JSON body, so the message never reaches the page. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent b31e9b7 commit f87e02b

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎integration/tests/tanstack-start/keyless.test.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ test.describe('Keyless mode @tanstack-react-start', () => {
2525
app = await commonSetup.commit();
2626
await app.setup();
2727
await app.withEnv(appConfigs.envs.withKeyless);
28-
// Without keys the app 500s on every request, so readiness can't wait for a 2xx
29-
await app.dev({ acceptAnyResponse: true });
28+
// Without keys the app 500s on every request (opaque JSON body), so readiness can't wait for a 2xx and the error is asserted from the detached server's stderr file
29+
await app.dev({ acceptAnyResponse: true, detached: true });
3030
});
3131

3232
test.afterAll(async () => {
@@ -38,8 +38,11 @@ test.describe('Keyless mode @tanstack-react-start', () => {
3838
}) => {
3939
const response = await page.goto(`${app.serverUrl}/`);
4040
expect(response?.status()).toBe(500);
41-
await expect(page.getByText('Publishable key is missing').first()).toBeVisible();
42-
await expect(page.getByText('npx clerk@latest init').first()).toBeVisible();
41+
42+
const stderrLogs = (await fs.readdir(app.appDir)).filter(f => f.endsWith('.err.log'));
43+
const stderr = (await Promise.all(stderrLogs.map(f => fs.readFile(path.join(app.appDir, f), 'utf-8')))).join('\n');
44+
expect(stderr).toContain('Publishable key is missing');
45+
expect(stderr).toContain('npx clerk@latest init');
4346
});
4447

4548
test('Claimed application with keys inside .env boots and serves the app.', async ({ page, context }) => {

0 commit comments

Comments
 (0)