rxjs-marbles is an RxJS marble testing library that should be compatible with any test framework. It wraps the RxJS TestScheduler and provides methods similar to the helper methods used the TestScheduler API.
Questions tagged [rxjs-marbles]
53 questions
2
votes
1 answer
How to write unit test for effect that after n times return a valid response?
I have to write Unit Test for this effect that is calling the service every 1 sec when it went in error.
I need to test for example that after 3 times of calling a service, I'll receive a good response.
I tried some way to test but without any…

fedexo
- 62
- 5
1
vote
2 answers
expectObservable().toBe() only receives last value of stream
I want to test a service that uses internally a BehaviorSubject to hold the state and exposes Observables with a distinctUntilChanged() in the pipe. When I run the following test, than the actual steam that is compared with my expectations only…

stofl
- 2,950
- 6
- 35
- 48
1
vote
1 answer
How to test that a series of function calls on a service produce the expected series of emitted values from an Observable on that same service
I have the following service:
export class MathService {
private _total = new BehaviorSubject(0);
total$ = this._total.asObservable();
add(num: number) {
this._total.next(this._total.value() + num);
}
subtract(num: number) {
…

snowfrogdev
- 5,963
- 3
- 31
- 58
1
vote
1 answer
swap element in an observable array
I am trying to swap two items in the observable array. I know how to do it in the normal array. I tried the same way but it doesn't change the value.
My Stackblitz code
Here is what I tried,
swapObservableArray() {
let index;
// get the…

anonymous
- 1,499
- 2
- 18
- 39
1
vote
2 answers
TS saying that object property dosn't exists while showing it does
I'm having a problem where I'm getting an error message on the return value of a stubbed function, that mocks the return of an Observable (using rxjs-marbles).
The issue I'm having is that the error message seems to state that a property of an…

Einar Ólafsson
- 3,036
- 1
- 19
- 24
1
vote
1 answer
Why are there 3 additional frames when marble testing Observables that error out?
I am testing the following redux-observable epic:
export const loginEpic: Epic = (action$, state$, { ajax }) => action$.pipe(
filter(isOfType(LOGIN)),
mergeMap(action => login(action.payload.credentials, ajax).pipe(
…

George S
- 323
- 3
- 15
1
vote
2 answers
Testing NGRX effect that emits action with delay OR does not emit anything
I have an NGRX effect that - depending on the state - emits an action with a delay or it emits nothing.
I want to write a test, covering both situations.
This is the effect:
myEffect$ = createEffect(() =>
this.actions$.pipe(
ofType(MyAction),
…

Jan
- 191
- 6
1
vote
2 answers
How do I marble-test an observable of void values?
Using RXJS's TestScheduler, is there a nice way to marble-test an event-like observable that emits undefined values?
I am using TypeScript, so type circumvention / monkey-patching is not desirable.
testScheduler.schedule(() => valueEmittingWork(),…

wh1t3cat1k
- 3,146
- 6
- 32
- 38
1
vote
0 answers
How to test concatenate streams in rxjs
The given class has a method which returns a cached stream but that stream can be triggered by another private hot stream which makes the cached stream emits a new value.
The class
export class SomeClass {
private cache: Observable;
…

constantant
- 1,192
- 1
- 13
- 25
1
vote
1 answer
unable to write a test case with marbel testing
I have created this function because for all the requests my application sends out using http.post, this is how different parts handle the response. So rather than duplicating the code, I thought to create a function. I want to simulate error…

Manu Chadha
- 15,555
- 19
- 91
- 184
1
vote
1 answer
Angular - testing Observable with Pairwise operator
I am using Angular and have been writing Unit tests for a while using jasmine-marbles. This is a scenario I can't seem to figure out. How would I test the determineNextSteps$? I am open to other solutions for testing this as well besides using…

Camden Brown
- 13
- 3
1
vote
1 answer
Jasmine using marbles to test multiple observable values
So I am trying to test the HTML based on if an observable emits certain values. I have the inital setup of the service to have an observable emit the correct value but when I go to create another test to test if what happens if I pass wrong data I…

Zach Starnes
- 3,108
- 9
- 39
- 63
1
vote
1 answer
RxJS marble testing objects with functions
I am returning from the Observable an object. One of its properties is a function.
After assigning even empty function and emitting the object the toBeObservable expectation fails because of non-deep match.
I'm using rxjs-marbles/jest for testing.…

m.cichacz
- 749
- 9
- 21
1
vote
1 answer
RxJs marble testing retryWhen
I have a SocketService. This class is responsible for socket connection and messaging with a server. I've written some code to make my client able to reconnect on connection loss. It should make 3 attempts with 5 sec delay between them and if no…

Sergey
- 7,184
- 13
- 42
- 85
1
vote
1 answer
Test observable mapping using marbles
I have a method that takes an observable as an input and switches to new observable. Alternatively, I could use map instead of switchMap. How can this be tested using marbles?
mapFirstToStr(ob: Observable): Observable {
return…

Martin
- 1,877
- 5
- 21
- 37