Skip to content

Conversation

@nlynzaad
Copy link
Contributor

@nlynzaad nlynzaad commented Jan 5, 2026

The raw stream tests in react-start-basic has some flaky behavior in that it tries to validate the results at times prior to it being available.

This PR attempts to address it by only displaying the results when available and in turn waiting for the specific element to be displayed. This should provide us a bit more accuracy in validating only after the results are available.

Summary by CodeRabbit

Release Notes

  • Tests
    • Enhanced raw stream E2E tests with improved result visibility handling and conditional display of test result blocks.
    • Strengthened test assertions with explicit visibility waits and more robust text content verification patterns across 16 test scenarios.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

Two files in the raw-stream test suite were updated: the client component now conditionally hides test result blocks by default, and corresponding e2e tests were refactored to explicitly wait for elements to become visible before reading their text content and performing assertions.

Changes

Cohort / File(s) Summary
Raw-stream UI and Tests
e2e/react-start/basic/src/routes/raw-stream/client-call.tsx, e2e/react-start/basic/tests/raw-stream.spec.ts
Client component: import reordering of raw-stream-fns exports; conditional rendering of test result blocks (tests 1–16) now hidden by default when results.testX is falsy. Test file: replaced inline toContainText assertions with explicit textContent retrieval after visibility waits; assertion pattern changed from per-call element checks to single text blob retrieval followed by multiple substring containment checks (15000 ms timeout, affecting tests 1–16).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~13 minutes

Possibly related PRs

Suggested labels

package: start-client-core

Poem

🐰 A rabbit tidies tests with patience and care,
Hiding results first, then revealing them fair,
Wait for the moment, collect what you see,
No rushing ahead—let the data flow free!
With visibility assured and assertions refined,
The tests run clearer, both thorough and kind! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding explicit waits for test results before validating raw stream tests in the react-start-basic suite, which aligns with the core objective of fixing flaky test behavior.
✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link

nx-cloud bot commented Jan 5, 2026

View your CI Pipeline Execution ↗ for commit 5ccf30d

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 8m 53s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-05 17:49:17 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 5, 2026

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6307

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6307

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6307

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6307

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6307

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6307

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6307

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6307

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6307

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6307

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6307

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6307

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6307

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6307

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6307

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6307

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6307

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6307

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6307

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6307

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6307

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6307

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6307

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6307

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6307

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6307

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6307

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6307

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6307

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6307

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6307

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6307

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6307

@tanstack/vue-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6307

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6307

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6307

@tanstack/vue-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6307

@tanstack/vue-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6307

@tanstack/vue-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6307

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6307

commit: 5ccf30d

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
e2e/react-start/basic/tests/raw-stream.spec.ts (1)

29-37: Excellent approach to fixing flaky tests.

The new pattern—wait for visibility, read textContent() once, then perform multiple assertions—effectively addresses the race condition where assertions ran before results were available. The consistent application across all 16 client RPC tests ensures reliability.

Optional: Add null check for defensive coding

textContent() can return null. While unlikely after a successful visibility wait, adding a null check or assertion would make the tests more robust:

 const result = await page.getByTestId('test1-result').textContent()
+expect(result).not.toBeNull()

 expect(result).toContain('chunk1chunk2chunk3')

Apply this pattern to all affected tests if desired.

Also applies to: 49-58, 70-78, 90-98, 110-118, 128-136, 259-267, 277-284, 294-301, 311-318, 328-335, 474-486, 497-504, 516-528, 614-622, 633-642

e2e/react-start/basic/src/routes/raw-stream/client-call.tsx (1)

12-34: Consider deferring import reordering to a separate PR.

The import reordering appears unrelated to fixing the flaky tests described in the PR objectives. While organizational changes can improve code maintainability, including them in a targeted bug-fix PR increases the diff size and makes the functional changes less obvious.

If the reordering serves a specific purpose (e.g., preparing for upcoming changes or resolving a linting issue), consider documenting that rationale in the PR description.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3e7d80 and 5ccf30d.

📒 Files selected for processing (2)
  • e2e/react-start/basic/src/routes/raw-stream/client-call.tsx
  • e2e/react-start/basic/tests/raw-stream.spec.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use TypeScript strict mode with extensive type safety for all code

Files:

  • e2e/react-start/basic/src/routes/raw-stream/client-call.tsx
  • e2e/react-start/basic/tests/raw-stream.spec.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Implement ESLint rules for router best practices using the ESLint plugin router

Files:

  • e2e/react-start/basic/src/routes/raw-stream/client-call.tsx
  • e2e/react-start/basic/tests/raw-stream.spec.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: hokkyss
Repo: TanStack/router PR: 5418
File: e2e/react-start/custom-identifier-prefix/src/styles/app.css:19-21
Timestamp: 2025-10-09T12:59:02.129Z
Learning: In e2e test directories (paths containing `e2e/`), accessibility concerns like outline suppression patterns are less critical since the code is for testing purposes, not production use.
Learnt from: hokkyss
Repo: TanStack/router PR: 5418
File: e2e/react-start/custom-identifier-prefix/public/site.webmanifest:2-3
Timestamp: 2025-10-09T12:59:14.842Z
Learning: In e2e test fixtures (files under e2e directories), empty or placeholder values in configuration files like site.webmanifest are acceptable and should not be flagged unless the test specifically validates those fields.
📚 Learning: 2025-11-02T16:16:24.898Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5732
File: packages/start-client-core/src/client/hydrateStart.ts:6-9
Timestamp: 2025-11-02T16:16:24.898Z
Learning: In packages/start-client-core/src/client/hydrateStart.ts, the `import/no-duplicates` ESLint disable is necessary for imports from `#tanstack-router-entry` and `#tanstack-start-entry` because both aliases resolve to the same placeholder file (`fake-start-entry.js`) in package.json during static analysis, even though they resolve to different files at runtime.

Applied to files:

  • e2e/react-start/basic/src/routes/raw-stream/client-call.tsx
📚 Learning: 2025-12-25T13:04:55.492Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 6215
File: e2e/react-start/custom-basepath/package.json:13-17
Timestamp: 2025-12-25T13:04:55.492Z
Learning: In the TanStack Router repository, e2e test scripts are specifically designed to run in CI (which uses a Unix environment), so Unix-specific commands (like `rm -rf`, `&` for backgrounding, and direct environment variable assignments without `cross-env`) are acceptable in e2e test npm scripts.

Applied to files:

  • e2e/react-start/basic/src/routes/raw-stream/client-call.tsx
📚 Learning: 2025-10-08T08:11:47.088Z
Learnt from: nlynzaad
Repo: TanStack/router PR: 5402
File: packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.nonnested.snapshot.ts:19-21
Timestamp: 2025-10-08T08:11:47.088Z
Learning: Test snapshot files in the router-generator tests directory (e.g., files matching the pattern `packages/router-generator/tests/generator/**/routeTree*.snapshot.ts` or `routeTree*.snapshot.js`) should not be modified or have issues flagged, as they are fixtures used to verify the generator's output and are intentionally preserved as-is.

Applied to files:

  • e2e/react-start/basic/src/routes/raw-stream/client-call.tsx
📚 Learning: 2025-10-09T12:59:02.129Z
Learnt from: hokkyss
Repo: TanStack/router PR: 5418
File: e2e/react-start/custom-identifier-prefix/src/styles/app.css:19-21
Timestamp: 2025-10-09T12:59:02.129Z
Learning: In e2e test directories (paths containing `e2e/`), accessibility concerns like outline suppression patterns are less critical since the code is for testing purposes, not production use.

Applied to files:

  • e2e/react-start/basic/tests/raw-stream.spec.ts
⏰ 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: Preview
  • GitHub Check: Test
🔇 Additional comments (1)
e2e/react-start/basic/src/routes/raw-stream/client-call.tsx (1)

91-96: Conditional visibility enables reliable test synchronization.

Adding className={results.testX ? '' : 'hidden'} to all test result blocks is the UI-side solution that makes the test fix work. By hiding elements until results are available, the tests can now reliably wait for visibility as a signal that data is ready to validate.

Also applies to: 116-121, 141-146, 166-171, 195-200, 220-225, 257-262, 285-290, 313-318, 343-348, 371-376, 410-415, 438-443, 474-479, 508-513, 545-550

@nlynzaad nlynzaad merged commit fb88aad into main Jan 5, 2026
6 checks passed
@nlynzaad nlynzaad deleted the flaky-stream-test branch January 5, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants