Conversation
…Client found' throw when 'loadDevtools' is 'true' without a 'QueryClient'
📝 WalkthroughWalkthroughA new test case was added to verify that when Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 6653ce5
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version PreviewNo changeset entries found. Merging this PR will not cause a version bump for any packages. |
size-limit report 📦
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/angular-query-experimental/src/__tests__/with-devtools.test.ts (1)
170-178: Align async flushing with the suite’s fake-timer pattern to reduce flakiness.Since fake timers are enabled globally, this test is more deterministic if it advances timers before settling dynamic imports (like other tests in this file). Also consider asserting
console.errorcall count.Suggested tweak
TestBed.inject(ENVIRONMENT_INITIALIZER) - TestBed.tick() + await vi.advanceTimersByTimeAsync(0) + TestBed.tick() await vi.dynamicImportSettled() + TestBed.tick() + await vi.dynamicImportSettled() expect(mockTanstackQueryDevtools).not.toHaveBeenCalled() + expect(consoleErrorSpy).toHaveBeenCalledTimes(1) expect(consoleErrorSpy).toHaveBeenCalledWith( 'Install `@tanstack/query-devtools` or reinstall without --omit=optional.', expect.objectContaining({ message: 'No QueryClient found' }), )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/angular-query-experimental/src/__tests__/with-devtools.test.ts` around lines 170 - 178, Advance the fake timers with TestBed.tick() (or equivalent) before awaiting vi.dynamicImportSettled() in the test that calls TestBed.inject(ENVIRONMENT_INITIALIZER) so dynamic imports are flushed under the suite's fake-timer pattern; then await vi.dynamicImportSettled(), and add an assertion on consoleErrorSpy call count (e.g., toHaveBeenCalledTimes(1)) alongside the existing expect statements for mockTanstackQueryDevtools and the console error message to reduce flakiness and make the expectation explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/angular-query-experimental/src/__tests__/with-devtools.test.ts`:
- Around line 170-178: Advance the fake timers with TestBed.tick() (or
equivalent) before awaiting vi.dynamicImportSettled() in the test that calls
TestBed.inject(ENVIRONMENT_INITIALIZER) so dynamic imports are flushed under the
suite's fake-timer pattern; then await vi.dynamicImportSettled(), and add an
assertion on consoleErrorSpy call count (e.g., toHaveBeenCalledTimes(1))
alongside the existing expect statements for mockTanstackQueryDevtools and the
console error message to reduce flakiness and make the expectation explicit.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 888d4093-e12a-4839-8515-063711043305
📒 Files selected for processing (1)
packages/angular-query-experimental/src/__tests__/with-devtools.test.ts
…Client found' throw when 'loadDevtools' is 'true' without a 'QueryClient' (TanStack#10544)
🎯 Changes
Adds a test covering the
throw new Error('No QueryClient found')branch inwith-devtools.ts(line 109). WhenloadDevtools: trueis set but noQueryClientis provided (e.g.provideTanStackQueryis missing), the dynamic devtools loader now has explicit coverage that the error is thrown and handled by the.catchbranch.What's tested
withDevtools(() => ({ loadDevtools: true })).ɵprovidersis registered withoutprovideTanStackQuery(queryClient).ENVIRONMENT_INITIALIZER+ one change detection cycle starts the dynamicimport('@tanstack/query-devtools')..then,getResolvedQueryClient()throws because neitherdevtoolsOptions().clientnor the optionally injectedQueryClientis present..catchbranch catches the thrown error and logs it viaconsole.error.Line 169 (
console.errorin the.catch) is covered as a natural consequence of the thrown error being propagated through the Promise chain.✅ Checklist
🚀 Release Impact
Summary by CodeRabbit