-
Notifications
You must be signed in to change notification settings - Fork 3k
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
debounceTime
does not emit with jasmine.clock.tick
in v7
#6382
Comments
Thanks. This is a bug. rxjs/src/internal/scheduler/intervalProvider.ts Lines 18 to 25 in 53ef494
Instead, the provider should obtain the |
Nope. That's not the problem. The rxjs/src/internal/operators/debounceTime.ts Lines 84 to 86 in 53ef494
and rxjs/src/internal/operators/debounceTime.ts Lines 99 to 100 in 53ef494
So the issue is that Jasmine purports to mock the clock, but it does not patch |
Apparently, Jasmine now has a beforeEach(() => {
jasmine.clock().install()
jasmine.clock().mockDate();
}); Calling that resolves the issue. |
Ugh. Jasmine. There's a reason we stopped using it on this project. Haha. |
Thanks for figuring this out for me. I confirmed it worked on a subset of tests and am rolling out the fix to the rest of the codebase. |
@benlesh the operator is broken in |
@matheo @avast-ye found a work around for it: change You can also mock it inside your tests: import { interval } from 'rxjs';
import { debounce } from 'rxjs/operators';
import * as rxjsOperators from 'rxjs/operators';
// inside beforeEach
jest.spyOn(rxjsOperators, 'debounceTime').mockImplementation((timeout) => debounce(() => interval(timeout))); Found here. |
I know the issue is closed, but has anyone found a definitive solution? I just upgraded to v7 and am facing the same problem using Jest. |
Hey @AntonioEduardo1998 @ortegamarcel , thank you a lot for these ideas! Do you know if there is any recent approach that is able as well to use fakeAsync with |
Bug Report
\cc @leggechr
Current Behavior
In v7,
debounceTime
does not emit any values when installing the jasmine clock and usingtick
. (This works in v6)Expected behavior
rxjs is compatible with jasmine.clock, or there is a documented workaround.
Reproduction
Note the reproductions below contain examples using the jasmine clock (which fails in v7) and the native clock (which succeeds).
v7: https://stackblitz.com/edit/rxjs-v7-debouncetime?file=test.ts
v6: https://stackblitz.com/edit/rxjs-v6-debouncetime?file=test.ts
The text was updated successfully, but these errors were encountered: