Questions tagged [rxjs-test-scheduler]

The TestScheduler library is rxjs' in-built testing library. Use this tag for questions around unit testing rxjs streams using the TestScheduler object.

The TestScheduler is used to build unit tests when testing rxjs streams of data. These streams are often difficult to test using traditional testing techniques (in javascript) as rxjs does not use a traditional promises or even the in built javascript timer.

The library exists at:

import { TestScheduler } from 'rxjs/testing';

More information on using this library can be found at https://rxjs-dev.firebaseapp.com/guide/testing/marble-testing

8 questions
11
votes
2 answers

The right way to test rxjs

I brought the book "rxjs in action" and just finish the testing section. Testing rxjs codes are different then usual testing, because everything are lazy loading. In the book, they mention two test method, either passing done(I am using QUnit and…
softshipper
  • 32,463
  • 51
  • 192
  • 400
2
votes
1 answer

Frame differs in running all test from running only one test, why?

If I run all tests for one epic at once only the first test passes. The other tests fail because the frame differs. But every test singly run passes. I could not find any related problem to this nether found something in the RxJS not the redux…
Finn
  • 23
  • 5
1
vote
1 answer

How to test RxJS observable that emits multiple values in 1 frame?

Given the following code: import {merge, Observable} from "rxjs"; export function springLatch(handle$: Observable, closedByDefault: boolean): Observable { const latch$ = new Observable((subscriber) => { if…
Byebye
  • 934
  • 7
  • 24
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
2 answers

angular rxjs marble test no values emitted

I try to test a simple angular component using a marble test. For that I'm using the TestScheduler which comes together with rxjs. Here is a stackblitz link with the code: https://stackblitz.com/edit/angular-ivy-xwzn1z This is a simplified version…
Mikelgo
  • 483
  • 4
  • 15
0
votes
0 answers

Testing infinite observables with Jest and TestScheduler

I am currently creating a test for a complex observable inside of an Angular project, but the test does not work at all (JavaScript heap out of memory). Basically the Observable emits a new value from a REST service every n seconds (the polling…
0
votes
0 answers

RxJS marble test fail with operator delay()

I have the following test, it works... import { TestScheduler } from 'rxjs/internal/testing/TestScheduler'; describe('RxJx', () => { const testScheduler = new TestScheduler((actual, expected) => { console.log('works here?'); …
0
votes
1 answer

TestScheduler for subject

I am trying to call .next on a simple subject submitTask$. My pipeline is this: export const submitTask$ = new Subject(); function epic() { return submitTask$.pipe( map(taskId => { console.log('here'); return Boolean(taskId) …
Noitidart
  • 35,443
  • 37
  • 154
  • 323