spectator
spectator copied to clipboard
Spectator does not play well with `takeUntilDestroyed`
Is this a regression?
No
Description
The operator takeUntilDestroyed
is used to complete an observable when the calling context is destroyed:
https://angular.dev/api/core/rxjs-interop/takeUntilDestroyed
- ✔️ With regular
TestBed
, when the context is destroyed, observables are well completed - ❌ With spectator, when the context is destroyed, observables may remain not completed
Please provide a link to a minimal reproduction of the bug
https://gist.github.com/devfservant/65335449c0ab8241bd9af9d084f5232a
Disclaimer: I was not able to create a working Stackblitz with Angular 18 + Jest + Spectator 😕 (here is my last attempt: https://stackblitz.com/edit/stackblitz-starters-sspm11)
Please provide the exception or error you saw
In the provided Gist, there are 3 tests.
In each of those tests, an observable is subscribed with the takeUntilDestroyed
operator.
Therefore, we expect the observable's side effects to be isolated between each test.
The Gist shows that it is not the case with Spectator:
there are some console.log
from the first tests which appear in the 2dn & in the 3rd tests.
Please provide the environment you discovered this bug in
@angular/*: 18.2.x
@ngneat/spectator: 19.x.x
jest: 29.x.x
jest-preset-angular: 14.x.x
node: 20.10.0
Anything else?
Note: I have no issue when using @ngneat/until-destroy
library
(but I want to use the new takeUntilDestroyed
operator)
Do you want to create a pull request?
No