TanStack / TanStack/query

Weird bug with Angular unit tests

Open
#10,046 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

package: angular-query
Dominant language
TypeScript
Stars
50.3k
Forks
4.2k
Avg merge
18h 25m
Merged PRs (30d)
200

Description

Describe the bug

In the docs it says that in the unit tests we should await fixture.whenStable() so a query completes and we get its resulted data. It is true but if I add a class field that references to query.data the query's data becomes undefined.

Your minimal, reproducible example

https://github.com/ms-dosx86/test-when-stable

Steps to reproduce
  1. Run ng test
  2. See that the test passes
  3. Uncomment the commented line in app.ts
  4. Run the test again
  5. Test fails
Expected behavior

I'm not sure what's going on there but I have a feeling that creating a class field that references to query.data shouldn't cause such behaviour.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform
  • MacOS 26.0.1 (25A362)
  • Chrome 143.0.7499.193
Tanstack Query adapter

angular-query

TanStack Query version

5.90.22

TypeScript version

5.8.2

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior in the linked minimal example with ng test, comparing app.ts with the class-field line commented and uncommented. Start by tracing fixture.whenStable() and query.data in the Angular adapter. Done means the behavior is understood and the expected result is covered by a focused test.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.