Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spectator does not play well with takeUntilDestroyed #667

Open
devfservant opened this issue Sep 3, 2024 · 2 comments
Open

Spectator does not play well with takeUntilDestroyed #667

devfservant opened this issue Sep 3, 2024 · 2 comments

Comments

@devfservant
Copy link

devfservant commented Sep 3, 2024

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

Copy link

stackblitz bot commented Sep 3, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@devfservant and others