feat(jasmine): support Date.now in fakeAsyncTest#1009
Conversation
|
@JiaLiPassion const observable = new Observable((subscribe: any) => {
subscribe.next('hello');
});
observable.delay(1000).subscribe(v => {
result = v;
});You can write this to fix it: Observable.of('hello').delay(1000).subscribe(v => result = v);( Anyway, thanks for making my library obsolete! 👍 XD |
|
@Jopie64 , thank you for the comment. I didn't use |
|
I couldn't make this work, so I'm a bit confused. |
|
@alfaproject , with angular/angular#23108 merged, it should work, current |
|
But can't I use the latest version of |
|
@alfaproject , you can use latest version of declare let Zone: any;
const async = Zone[Zone.__symbol__('asyncTest')];
const { fakeAsync, tick, flush, flushMicrotasks, discardPeriodicTasks, resetFakeAsyncZone } = Zone[Zone.__symbol__('fakeAsyncTest')];and if you use (window as any)['__zone_symbol__fakeAsyncPatchLock'] = true;
import 'zone.js/dist/zone-testing';if you use Could you try this in your project to see everything work fine or not? thank you! |
|
@JiaLiPassion that works, thank you for helping! |
|
Tried this out but my tests are still broken as |
|
Okay so |
|
@JiaLiPassion Thanks for that, it's finally working though a note: I figured out the hard way that you have to import the delay operator above your snipped for this to function properly in angular 5: import { Observable } from "rxjs/Observable";
import "rxjs/add/operator/delay";
declare let Zone: any;
const async = Zone[Zone.__symbol__("asyncTest")];
const {fakeAsync, tick, flush, flushMicrotasks, discardPeriodicTasks, resetFakeAsyncZone} = Zone[Zone.__symbol__(
"fakeAsyncTest")];
import 'zone.js/dist/zone-patch-rxjs-fake-async'; |
|
Thanks @JiaLiPassion! |
|
@JiaLiPassion Where are we supposed to get fakeAsyncTestZone from to call fakeAsyncTestZone.run? |
|
@afeinber, do you mean you want to |
fix angular/angular#8678
support
Date.nowinfakeAsyncTest. there are3features in this PR.Date.nowandnew Date()infakeAsync.fakeAsynctest whenjasmine.clock().installis called.Schedulersupport, need to importzone.js/dist/zone-patch-rxjs-fake-async.@mhevery , @vikerman , please review, thank you!