Questions tagged [jasmine-marbles]
89 questions
5
votes
1 answer
How to flush one cold observable as opposed to all observables in the test?
getTestScheduler().flush() flushes all the observables in the test. Is there a way to granularly flush observables?
e.g. cold('--x', {x: {}}).flush()

Maxime Dupré
- 5,319
- 7
- 38
- 72
5
votes
1 answer
RxJs - lossy zip marble testing
Following this post I've decided to write a marble test for this operator.
Here is a basic test:
it('Test lossy zip', () => {
const a = hot('a---a--------a-');
const b = hot('--b----b---b---');
const observable = zip(
…

JeB
- 11,653
- 10
- 58
- 87
4
votes
0 answers
Ngrx Testing selector with jasmine marbles: Expected $.length = 1 to equal 2
I am trying to test a simple loader component which is getting its state from an ngrx selector I have made. The selector is providing an object (interface name is LoaderState) {queue: number} which I map in a boolean value to show or hide the…

dimitris maf
- 671
- 8
- 17
4
votes
1 answer
NGRX - Problem with testing effects that convert promises to observables with jasmine-marbles
I have a nrwl/nx workspace with a library called missions-shared This library has a feature state, under the key missions I also have a backend service, called BackendServiceClient. This backend returns promises (due to code generation)
My problem…

Ludovic C
- 2,855
- 20
- 40
4
votes
0 answers
Jasmine marbles testing NGRX effects
I'm trying to test an NGRX effect using jasmine-marbles but the response I get from effects.myEffect$ appears to have nested operators. What I was expecting was an observable returning a single, flat action. Any help or input would be greatly…

Simon Houlton
- 182
- 1
- 10
4
votes
1 answer
TypeError: expect(...).toBeObservable is not a function - Jasmine marbles
I am trying to write a basic ngrx effects testing. However I keep getting the error as TypeError: expect(...).toBeObservable is not a function.
This is a new project setup with Angular 7. I had no issues with my previous projects which ran in…

Anand
- 245
- 4
- 15
4
votes
1 answer
Testing async pipeable operators in RxJS
Sometimes we have functions, which modifies original source using async operators like delay.
Lets assume we have something really simple:
// Old syntax
function modify(source) {
return source.delay(1000);
}
I am using marbles to test RxJs, so…

ilyabasiuk
- 4,270
- 4
- 22
- 35
4
votes
1 answer
How to make an rxjs marble sync grouping only take up one frame
According to https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/testing/marble-testing.md#marble-syntax
'--(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,…

Giles Bradshaw
- 1,249
- 2
- 9
- 8
3
votes
0 answers
Test of takeUntil-using NGRX effect with jasmine-marbles does not complete as expected
Given two NGRX Effects (using nrwl/nx dataPersistence notation) where the second is bound to the first by takeUntil:
@Injectable()
export class ModuleEffects {
@Effect() effectOne$ = this.dataPersistence.fetch(ModuleActionTypes.ActionOne,…

Jens Habegger
- 5,266
- 41
- 57
3
votes
4 answers
Ngrx Effects spec throws Error as "No test scheduler initialized"
Trying to run a simple effects test with an existing and recently migrated Angular 7 project. But I get error as below.
Error: No test scheduler initialized
at getTestScheduler (node_modules/jasmine-marbles/es6/src/scheduler.js:11:1)
…

Anand
- 245
- 4
- 15
3
votes
3 answers
How to unit test withLatestFrom in ngrx effects
I have an effect that is taking the latest from params and passing that into an exhaustMap that then calls a service.
@Effect()
loadPlansOnParams$ = this.actions$.pipe(
ofType(backlogActions.BacklogActionTypes.GET_BOARDS_IN_PARAMS),
…

s.Lawrenz
- 302
- 3
- 17
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
0 answers
How to mock Angular HttpClient response within test of observable stream?
I have an observable that ultimately triggers a call to Angular HttpClient. I need to mock the response from the HttpClient, but I'm at a loss how to do it within the context of the TestScheduler run method. Say I have the following…

tek
- 343
- 1
- 4
- 10
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
2 answers
Jasmine marble testing observable with ngIf async pipe
I want to test an Observable with jasmine-marble testing, but unfortunately I can't figure out how to trigger change detection for ngIf, which should render the component.
This is a simplified version of my class:
export class MyComponent implements…

JB17
- 366
- 5
- 14