Skip to content

Conversation

arnoud-dv
Copy link
Collaborator

@arnoud-dv arnoud-dv commented Sep 21, 2025

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive Angular Testing guide for TanStack Query, covering setup with a fresh QueryClient per spec, cache isolation, PendingTasks, TestBed usage, Zone.js/zoneless considerations, retries configuration, HttpClientTestingModule with HttpTestingController, infinite queries/pagination, mutations with optimistic updates, and a quick reliability checklist.
    • Updated documentation navigation to include a “Testing” entry under both Getting Started and Guides & Concepts for Angular.

Copy link
Contributor

coderabbitai bot commented Sep 21, 2025

Walkthrough

Adds Angular testing documentation for TanStack Query and updates docs navigation to include a Testing entry under Angular guides in two sections.

Changes

Cohort / File(s) Summary
Docs: Navigation config
docs/config.json
Adds "Testing" nav links under Getting Started and Guides & Concepts pointing to framework/angular/guides/testing.
Docs: Angular Testing Guide
docs/framework/angular/guides/testing.md
Introduces comprehensive Angular testing guidance covering QueryClient per-spec setup, PendingTasks, TestBed usage, Zone/zoneless notes, retries, HttpClientTestingModule with HttpTestingController, infinite queries, mutations, and a quick checklist.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant T as Test (Jasmine/Jest)
  participant TB as Angular TestBed
  participant C as Component/Service
  participant QC as QueryClient (per spec)
  participant PT as PendingTasks
  participant HT as HttpTestingController

  T->>TB: configureTestingModule(...)
  TB->>QC: create new QueryClient({ defaultOptions... })
  TB->>C: instantiate with providers (QueryClient)
  note over QC,C: Isolated cache per spec

  T->>C: trigger query/mutation
  C->>PT: register async work (Query in-flight)
  C->>HT: expectOne('/api/...') and flush(mock)

  T->>PT: await stabilization (whenStable / pendingTasks)
  TB-->>T: stable, assert results
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

documentation

Poem

A nibble of tests, a hop through the queue,
I stash fresh caches like morning dew.
With PendingTasks I wait, then spring—
Mocked calls chirp, assertions sing.
Zoneless or zoned, I bound with glee,
Carrots for green checks—ship it, whee! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The title "docs(angular-query): add testing guide" accurately summarizes the primary change in this PR — the addition of an Angular testing guide and related navigation entries — and is concise and clear with an appropriate docs scope prefix. It reflects the main intent from the PR objectives and file summaries, so a reviewer scanning history will understand the primary change. The title could optionally be more specific by saying "unit testing" if you want to emphasize unit-focused content, but that is not required.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Sep 21, 2025
Copy link

nx-cloud bot commented Sep 21, 2025

View your CI Pipeline Execution ↗ for commit 19a2af6

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 12s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-21 00:21:16 UTC

Copy link

pkg-pr-new bot commented Sep 21, 2025

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9669

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9669

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9669

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9669

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9669

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9669

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9669

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9669

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9669

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9669

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9669

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9669

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9669

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9669

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9669

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9669

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9669

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9669

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9669

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9669

commit: 19a2af6

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: 2

🧹 Nitpick comments (4)
docs/config.json (1)

138-169: Optional: also surface “Testing” under Getting Started?

If the intent is extra discoverability for Angular newcomers, consider adding a cross‑link in the Angular “Getting Started” list as well. Other frameworks only list Testing under Guides, so skip if parity is preferred.

docs/framework/angular/guides/testing.md (3)

32-33: Grammar nit

Use the possessive form.

-> If your applications actual TanStack Query config is used in unit tests, ...
+> If your application's actual TanStack Query config is used in unit tests, ...

95-105: Minor clarity: show lastValueFrom import

Readers may copy/paste; a one‑liner import prevents confusion.

-    queryFn: () => lastValueFrom(TestBed.inject(HttpClient).get('/api/todos')),
+    // import { lastValueFrom } from 'rxjs'
+    queryFn: () => lastValueFrom(TestBed.inject(HttpClient).get('/api/todos')),

58-64: Timers guidance is good — add Jest alias for completeness (optional)

Many users are on Jest; add jest.advanceTimersByTimeAsync(0) as an alternative.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d7c90e and 19a2af6.

📒 Files selected for processing (2)
  • docs/config.json (1 hunks)
  • docs/framework/angular/guides/testing.md (1 hunks)
⏰ 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 (4)
docs/config.json (1)

710-713: Angular “Testing” nav entry looks correct

Link path matches the new guide and follows existing framework patterns.

docs/framework/angular/guides/testing.md (3)

150-158: Great checklist

Concise and actionable. No changes needed.


28-29: Provider API names confirmed (TanStack Query v5)

Both provideTanStackQuery(queryClient, ...features) — the primary app-level provider (accepts features like withDevtools()) — and provideQueryClient(queryClient) — a lower-level single-provider for scoping/tests — are current public APIs; the existing line providers: [provideTanStackQuery(queryClient)] is correct.


12-13: Confirm Angular 19+ requirement for PendingTasks

Verified: ExperimentalPendingTasks appeared in Angular 18 (developer-preview/experimental) and was renamed and stabilized as PendingTasks in Angular 19 — it's stable for testing from v19, so the current "Angular 19 or later" requirement is correct.

@arnoud-dv arnoud-dv changed the title docs(angular-query): add unit testing guide docs(angular-query): add testing guide Sep 21, 2025
@arnoud-dv arnoud-dv merged commit 06e5550 into TanStack:main Sep 21, 2025
6 checks passed
@arnoud-dv arnoud-dv deleted the docs/angular-unit-testing branch September 21, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant