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
9
votes
2 answers
Test Angular Reactive Forms using RxJS Marbles
Angular Component
public setupObservables() {
this.formFieldChanged$ = this.formField
.valueChanges
.pipe(
debounceTime(100),
distinctUntilChanged((a, b) => a === b),
)
}
Jasmine Test
import { of } from 'rxjs';
import…

Vedran
- 10,369
- 5
- 50
- 57
8
votes
4 answers
Testing NGRX effect with delay
I want to test an effect that works as follows:
Effect starts if LoadEntriesSucces action was dispatched
It waits for 5 seconds
After 5 seconds passes http request is send
When response arrives, new action is dispatched (depending, whether response…

bartosz.baczek
- 1,567
- 1
- 17
- 32
6
votes
1 answer
Angular Unit Test: how to use marble testing (rxjs/testing) to test this state management service
In my angular project, I have a service, which is used for state management to share some data between components as following:
@Injectable({ providedIn: "root"})
export class NameStateService {
private _filteredNames$: Subject = new…

Chris Bao
- 2,418
- 8
- 35
- 62
5
votes
2 answers
RxJS combineLatest emit only once per path
Is there any way/pattern to use combineLatest() or some other operator so that if the combined observables depend on one another, they will only emit only once for each set of paths with the same origin in a DAG? I think it may be easier to explain…

Adam B.
- 788
- 5
- 14
5
votes
0 answers
How to use rxjs marbles testing with graphQL Apollo Testing Controller in Angular
I would like to test a GraphQL subscription in Angular that
Make a query
Attach a subscription to the query by using subscribeToMore
Mock the query result by using flush on its operation in and validate the result
Mock the subscription result by…

JoG
- 962
- 2
- 11
- 17
5
votes
1 answer
Test observable 'next' callback in RxJs and Angular
I'm trying to do a pretty simple test in Angular with RxJs Observables, but I'm coming up short. This is what I'm basically trying to test:
// We're inside some Angular component here...
let testMe = 0;
function somethingOrOther(): void {
…

Spencer
- 2,245
- 3
- 28
- 50
4
votes
2 answers
Order of execution with rxjs asapscheduler
Considering I have the following code:
let Rx = window['rxjs'];
const { of,
queueScheduler,
asapScheduler,
asyncScheduler,
animationFrameScheduler
} = Rx;
const { observeOn, tap } = Rx.operators;
console.clear();
let source$ =…

anonymous
- 1,499
- 2
- 18
- 39
4
votes
1 answer
How to test with the marble approach when the returm is a EMPTY observable in effect?
I am using EMPTY from rxjs in order to handle the catchError, What is the correct value for expected in order to pass the fail scenario.
import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from…

Tabares
- 4,083
- 5
- 40
- 47
3
votes
1 answer
RxJs test for multiple values from the stream
Given the following class:
import { BehaviorSubject } from 'rxjs';
import { map } from 'rxjs/operators';
export class ObjectStateContainer {
private currentStateSubject = new BehaviorSubject(undefined);
private $currentState =…

peinearydevelopment
- 11,042
- 5
- 48
- 76
3
votes
1 answer
Jest RXjs6 Marbles, how to test existing observable
I am trying to figure out how to structure a jest unit test for the following:
I have a bunch of existing observables and subjects I want to test in a project. So I have started off with what I would assume to be a simple test case using RXjs…

user2765977
- 491
- 4
- 18
3
votes
1 answer
RxJs marble testing : Assertion fail log hard to understand
I have this Rxjs testing code. It fail deliberately, because i want to show you the failing log. Which i found hard to understand, or at least i cannot read it fluently.
Someone can explain me what means : $[i].frame = i' to equals i'' ?
import {…

bubbles
- 2,597
- 1
- 15
- 40
3
votes
2 answers
RxJS Marble testing: expectObservable vs toBeObservable
What is the difference between:
expectObservable(e1.merge(e2)).toBe(expected);
and
expect(e1.merge(e2)).toBeObservable(expected);
syntax?
Is it matter of a testing library or just a flavor?

Felix
- 3,999
- 3
- 42
- 66
2
votes
1 answer
How to mock observable from service in marble testing
I want to test an Angular service which contains my logic. I will simplify my case in order to make it straightforward :
I have logic$ which is what I want to test, it is bound to data$, another observable
@Injectable({
providedIn:…

Hervé TCHIKLADZE
- 23
- 2
2
votes
0 answers
How to pause and resume virtual time when using marble testing with rxjs?
I'm trying to write a test for an object that has both reactive elements and non-nonreactive elements. I cannot figure out how to write the marble diagrams so the test is legible.
In the test below, I have an object I'm testing that both stores a…

Stephen Jennings
- 12,494
- 5
- 47
- 66
2
votes
1 answer
Why does rxjs 6 marbles documentation say "--(abc)-|" completes on frame 8?
I am reading over the marbles testing documentation for Rxjs 6, and found this part under the "Examples" section for "Marble Syntax"
https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/testing/marble-testing.md#examples
Here is the…

Reactgular
- 52,335
- 19
- 158
- 208