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

Pending timers using fakeAsync #2240

Open
Undestor opened this issue Apr 17, 2024 · 1 comment
Open

Pending timers using fakeAsync #2240

Undestor opened this issue Apr 17, 2024 · 1 comment

Comments

@Undestor
Copy link

Describe the bug

After updating @apollo/client (from v.3.8.10 to v.3.9.xx) we have pending timers in our tests using fakeAsync. I am not 100% sure if this is a problem which only occurs using the testing utils (apollo-angular/testing).

To Reproduce
The following code snippet has no pending timers using @apollo/client v.3.8.10. After updating to v.3.9.xx is has 3 pending timers.

it('should have no pending timers', fakeAsync(() => {
    const apollo = TestBed.inject(Apollo)
    apollo
	    .query<SomeQueryType>({
		    query: SomeQuery,
		    variables: { id: someUuid },
		    errorPolicy: 'all',
	    })
	    .subscribe(() => console.log('value changed'))
    apolloCtrl.expectOne(extractOperationNameFromQuery(SomeQuery)).flush(SomeQueryPayload)
    tick()
}))

Expected behavior

There should be no timers pending

Environment:

- @angular/cli@17.3.0
- @angular/core@17.3.3
- @apollo/client@3.9.11
- apollo-angular@6.0.0
- graphql@16.8.1
- typescript@5.4.4

Additional context

@PowerKiKi
Copy link
Collaborator

I experienced the same behavior change. But since apollo-angular did not change anything, I expect this should be reported to @apollo/client, not here.

In the meantime, you can use flush(); at the end of your tests, as a workaround to discard those pending timers.

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