Questions tagged [jasmine-marbles]
89 questions
11
votes
1 answer
How to fix Expected $.length = 2 to equal 1
I want to test ngLogger function with jasmine marble but a got error
Expected $.length = 2 to equal 1.
Expected $.length = 2 to equal 1.
Expected $[0].frame = 0 to equal 10.
Expected $[0].notification.value to be a kind of Observable, but was…

Ursule Maffo
- 113
- 1
- 1
- 6
10
votes
1 answer
How to test Subject with jasmine marbles
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…

wilver
- 2,106
- 1
- 19
- 26
9
votes
1 answer
ngrx + marble testing + delay
Let's say I have an effect
@Effect()
someEffect$ = this.actions$.pipe(ofType(X), switchMap(() =>
of(Y).pipe(delay(3000)))
How should marble test look like?
const action = new X();
const result = new Y();
actions$.stream = hot('-x', { x: action…

Cor Kalom
- 91
- 2
8
votes
2 answers
Testing fail action - marble - ngrx Effects
I've got an issue testing a failed action on my effects.
To give a bit of context here loadProducts effect is executed when the Load action is called. Inside the effect an HTTP request is performed, in case this request is executed successfully the…

Denis Alejandro Salazar Rojas
- 133
- 1
- 7
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
7
votes
1 answer
Peculiar result from observable: testing with Jasmine marbles
I have a little function in Angular 7 that I am testing with Jest. The function looks like this:
private checkFreeProduct(allowance: SubscriberConnectivityAllowanceInterface): Observable {
// TODO: This…

serlingpa
- 12,024
- 24
- 80
- 130
7
votes
2 answers
How to test observables which emit grouped events with rxjs marbles?
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…

kazinov
- 701
- 1
- 6
- 11
7
votes
1 answer
Timing / Framing issue with Jasmine-marbles using hot and cold
I've got a quick demo people can download here: https://stackblitz.com/edit/angular-vczzqp Just hit export in the top right, in your favourite terminal and run install and ng test with your favourite browser.
Basically the issue, to me, seems to be…

Questioning
- 1,903
- 1
- 29
- 50
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
6
votes
1 answer
RxJs - Jasmine marbles forkJoin operator test
Here is forkJoin operator jasmine marble test:
it('test1', () => {
const a = cold('---a|', { a: 1 });
const b = cold('---b|', { b: 2 });
const observable = forkJoin(
a,
b
);
const expected = cold('---21');
…

tsiro
- 2,323
- 3
- 24
- 46
5
votes
2 answers
Unit Test NGRX effect with Marbles for an external URL
When an effect is triggered, i would like to test both observables in unit test, to get a 100% code coverage for this part of code. because a window.location.href is triggered, I can't test it correctly.
export class RouteHelper {
static…

rvdm
- 213
- 2
- 9
5
votes
1 answer
How to test timeout() in a rxjs pipe with jasmine-marbles
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,…

Jodi
- 73
- 1
- 7
5
votes
1 answer
Marble test fails with Jest, but equivalent test succeeds with Jasmine
I'm trying to convert my unit tests from Jasmine to Jest. Some tests started to fail after converting them to Jest. Can someone explain why they fail with Jest.
I managed to isolate the problem to the test case below.
With Jasmine is runs…

stijnvn
- 356
- 2
- 12
5
votes
1 answer
Marble testing a subject's behavior over time with jasmine-marbles
So I'm trying to test a Subject's behavior and it's not working, and it seems like there some things I'm not understanding correctly. Consider the following test:
it('marble testing subject test', () => {
const obs$: Subject = new…

sovemp
- 1,402
- 1
- 13
- 31
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