Skip to content

Weird bug with Angular unit tests #10046

@ms-dosx86

Description

@ms-dosx86

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions