jasmine-marbles

How to test timeout() in a rxjs pipe with jasmine-marbles

て烟熏妆下的殇ゞ 提交于 2020-02-25 13:36:38
问题 I have written a pipe that filters an input observable. In the pipe I specify a timeout with the timeout() operator to abort waiting if the expected value is not emitted by the source in time. I want to test the timeout case with jasmine-marbles, but I can't get it to work. I believe that expect(source).toBeObservable() evaluates before the source emits. see Stackblitz The pipe to be tested: source = cold('a', { a: { id: 'a' } }).pipe( timeout(500), filter((a) => false), catchError((err) => {

How to test timeout() in a rxjs pipe with jasmine-marbles

﹥>﹥吖頭↗ 提交于 2020-02-25 13:36:30
问题 I have written a pipe that filters an input observable. In the pipe I specify a timeout with the timeout() operator to abort waiting if the expected value is not emitted by the source in time. I want to test the timeout case with jasmine-marbles, but I can't get it to work. I believe that expect(source).toBeObservable() evaluates before the source emits. see Stackblitz The pipe to be tested: source = cold('a', { a: { id: 'a' } }).pipe( timeout(500), filter((a) => false), catchError((err) => {

How to test timeout() in a rxjs pipe with jasmine-marbles

女生的网名这么多〃 提交于 2020-02-25 13:36:07
问题 I have written a pipe that filters an input observable. In the pipe I specify a timeout with the timeout() operator to abort waiting if the expected value is not emitted by the source in time. I want to test the timeout case with jasmine-marbles, but I can't get it to work. I believe that expect(source).toBeObservable() evaluates before the source emits. see Stackblitz The pipe to be tested: source = cold('a', { a: { id: 'a' } }).pipe( timeout(500), filter((a) => false), catchError((err) => {

How to make an rxjs marble sync grouping only take up one frame

纵饮孤独 提交于 2019-12-19 10:05:15
问题 According to https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md '--(abc)-|': on frame 20, emit a, b, and c, then on frame 80 complete So how do I represent "on frame 20, emit a, b, and c, then on frame 40 complete. Ie how can I stop the sync group itself taking up frames? 回答1: cartant has answered this question in his comment. There's no way to do it - sync groups will always take up extra frames even though all members occur in the frame of the opening bracket. 来源:

How to test observables which emit grouped events with rxjs marbles?

六月ゝ 毕业季﹏ 提交于 2019-12-07 09:11:47
问题 According to rxjs marbles documentation the current behaviour for the sync groupings is the following: '(ab)-(cd)': on frame 0, emits a and b then on frame 50, emits c and d From the docs: While it can be unintuitive at first, after all the values have synchronously emitted time will progress a number of frames equal to the number of ASCII characters in the group, including the parentheses Ok, but how do I test an observable like this (using marbles or any other technique): const observable$

How to test Subject with jasmine marbles

牧云@^-^@ 提交于 2019-12-07 05:26:59
问题 Angular 6, Rxjs, Jest, Jasmine-marbles. very common scenario: a component that searches for server-side items. In the component, there are some controls that can change search critera, and I'd like to code in "reactive-style". So in the component code I have something like this: class SearchComponent implements OnInit { public searchData: SearchData = {}; public searchConditions$ = new Subject<SearchData>(); constructor(private searchService: SearchService) { } public results$: Observable

How to test Subject with jasmine marbles

帅比萌擦擦* 提交于 2019-12-05 09:55:57
Angular 6, Rxjs, Jest, Jasmine-marbles. very common scenario: a component that searches for server-side items. In the component, there are some controls that can change search critera, and I'd like to code in "reactive-style". So in the component code I have something like this: class SearchComponent implements OnInit { public searchData: SearchData = {}; public searchConditions$ = new Subject<SearchData>(); constructor(private searchService: SearchService) { } public results$: Observable<ResultData> = this.searchConditions$.pipe( distinctUntilChanged(this.compareProperties), // omissis but it

How to make an rxjs marble sync grouping only take up one frame

孤者浪人 提交于 2019-12-01 10:38:58
According to https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md '--(abc)-|': on frame 20, emit a, b, and c, then on frame 80 complete So how do I represent "on frame 20, emit a, b, and c, then on frame 40 complete. Ie how can I stop the sync group itself taking up frames? cartant has answered this question in his comment. There's no way to do it - sync groups will always take up extra frames even though all members occur in the frame of the opening bracket. 来源: https://stackoverflow.com/questions/46839094/how-to-make-an-rxjs-marble-sync-grouping-only-take-up-one-frame