Skip to content

test(angular-query*): simplify 'TestBed' setup by removing redundant 'resetTestingModule' and leveraging provider merging#10546

Merged
sukvvon merged 1 commit intomainfrom
test/angular-query-simplify-testbed-setup
Apr 21, 2026
Merged

test(angular-query*): simplify 'TestBed' setup by removing redundant 'resetTestingModule' and leveraging provider merging#10546
sukvvon merged 1 commit intomainfrom
test/angular-query-simplify-testbed-setup

Conversation

@sukvvon
Copy link
Copy Markdown
Collaborator

@sukvvon sukvvon commented Apr 21, 2026

🎯 Changes

Simplifies TestBed setup across Angular tests by removing redundant resetTestingModule() calls and leveraging Angular's provider merging behavior — configureTestingModule() merges providers on repeated calls, so tests that only need to add extra providers on top of the beforeEach baseline no longer have to re-declare the whole provider array.

Per-file changes

  • angular-query-experimental/src/__tests__/inject-is-restoring.test.ts: extract common setup into a beforeEach hook and let the provideIsRestoring test merge its extra provider.
  • angular-query-experimental/src/__tests__/inject-mutation.test.ts: drop 4 resetTestingModule + configureTestingModule blocks that just re-declared the exact providers already set up in beforeEach.
  • angular-query-experimental/src/__tests__/inject-queries.test.ts: move the top-level beforeEach/afterEach hooks into the describe block they belong to, and simplify the isRestoring test to only declare the extra provider it needs.
  • angular-query-experimental/src/__tests__/inject-query.test.ts: remove 3 redundant resetTestingModule + full re-declaration blocks, and simplify the isRestoring / HttpClient tests to only declare their extra providers.
  • angular-query-experimental/src/__tests__/pending-tasks.test.ts: the nested HttpClient Integration describe now merges provideHttpClient / provideHttpClientTesting on top of the parent beforeEach instead of resetting and rebuilding from scratch.
  • angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts: move the top-level beforeEach/afterEach hooks into the describe block they belong to, matching the convention used in the rest of the suite.

Out of scope

Three TestBed.resetTestingModule() calls in with-devtools.test.ts are intentionally preserved — they're either cleanup in afterEach or part of the test's own subject ("injector destroy" behavior), not redundant setup.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Restructured test initialization across multiple test files to consolidate shared setup configurations, improving test maintainability and reducing redundant setup code without affecting test functionality or coverage.

…'resetTestingModule' and leveraging provider merging
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1339c22b-6152-4fe1-8827-910cabbab8ef

📥 Commits

Reviewing files that changed from the base of the PR and between ad3bc84 and 3dfc0f2.

📒 Files selected for processing (6)
  • packages/angular-query-experimental/src/__tests__/inject-is-restoring.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-mutation.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-queries.test.ts
  • packages/angular-query-experimental/src/__tests__/inject-query.test.ts
  • packages/angular-query-experimental/src/__tests__/pending-tasks.test.ts
  • packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts
💤 Files with no reviewable changes (1)
  • packages/angular-query-experimental/src/tests/inject-mutation.test.ts

📝 Walkthrough

Walkthrough

The PR refactors test setup across multiple Angular Query test files in the angular-query-experimental and angular-query-persist-client packages. Changes consolidate shared test initialization into outer beforeEach hooks and eliminate per-test TestBed configuration duplication by relying on parent scope setup instead of resetting modules within individual tests.

Changes

Cohort / File(s) Summary
Angular Query Experimental - TestBed Consolidation
packages/angular-query-experimental/src/__tests__/inject-is-restoring.test.ts, inject-mutation.test.ts, inject-query.test.ts
Removed repeated TestBed.resetTestingModule() and TestBed.configureTestingModule() calls from individual tests. Tests now rely on shared provider setup established in outer beforeEach blocks, with per-test configuration narrowed to only scenario-specific providers.
Angular Query Experimental - Test Structure Refactoring
packages/angular-query-experimental/src/__tests__/inject-queries.test.ts
Introduced top-level describe('injectQueries') block and moved queryClient and timer setup (beforeEach/afterEach) inside it. Updated nested isRestoring test to remove TestBed.resetTestingModule() and simplify provider configuration.
Angular Query Experimental - HTTP Provider Simplification
packages/angular-query-experimental/src/__tests__/pending-tasks.test.ts
Removed TestBed.resetTestingModule() call and reduced TestBed.configureTestingModule providers list in nested beforeEach to only HTTP providers (provideHttpClient(), provideHttpClientTesting()), removing base TanStack Query and zoneless providers.
Angular Query Persist Client - Timer Scope Refinement
packages/angular-query-persist-client/src/__tests__/with-persist-query-client.test.ts
Relocated Vitest fake-timer setup/teardown (vi.useFakeTimers(), vi.useRealTimers()) from module-level beforeEach/afterEach to be scoped within the describe('withPersistQueryClient') block, narrowing timer configuration scope.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 With carrot-ful refactoring, I've tidied the test home,
No more setup duplication where the test cases roam,
Shared beforeEach wisdom, less config to repeat,
Scoped with purpose and care—ah, how tidy and neat!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing redundant TestBed.resetTestingModule calls and leveraging provider merging across Angular query tests.
Description check ✅ Passed The description comprehensively covers all changes with per-file details, properly filled checklist, and clear scope boundaries including out-of-scope items.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/angular-query-simplify-testbed-setup

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

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 21, 2026

View your CI Pipeline Execution ↗ for commit 3dfc0f2

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

☁️ Nx Cloud last updated this comment at 2026-04-21 16:36:54 UTC

@sukvvon sukvvon self-assigned this Apr 21, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

No changeset entries found. Merging this PR will not cause a version bump for any packages.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 21, 2026

More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@10546

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@10546

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 3dfc0f2

@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.99 KB (0%)
react minimal 9.02 KB (0%)

@sukvvon sukvvon merged commit b79bb92 into main Apr 21, 2026
10 checks passed
@sukvvon sukvvon deleted the test/angular-query-simplify-testbed-setup branch April 21, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant