Questions tagged [jasmine-marbles]

89 questions
0
votes
1 answer

RxJs Marble testing concatMap with withLatestFrom

How can be unit tested this Observable? e1.pipe( concatMap(x => of(x).pipe(withLatestFrom(e2))) ); Following unit test fails: it('test', () => { const e1 = hot( '--1^---2----3-|'); const e2 = hot( …
user1610458
  • 311
  • 1
  • 5
  • 18
0
votes
1 answer

How to trigger error and test the method?

I am doing angular service test. it works fine. But I unable to achieve the 100% of testing, since the error function not tested. I tried my best. but not able to come up with 100%. any one help me? here is my service: export class…
user2024080
  • 1
  • 14
  • 56
  • 96
0
votes
0 answers

Getting an error as `should correctly return` while testing my service using `jasmine-marbles`

I am getting an error as: TypeError: actual.subscribe is not a function 19 | it('should correctly return', () => { 20 | const expectedValues = cold('--a', {a:[]}); > 21 | …
3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
0
votes
1 answer

Unexpected errors testing the ngrx mock store

I think I found a solution, go to the end of the question I have a simple test with jasmine-marbles and I am getting this error and I do not know what is happening. Any ideas? Expected $[0].notification.kind = 'E' to equal 'N'. Expected…
dmance
  • 628
  • 1
  • 8
  • 26
0
votes
0 answers

Unit testing with Jasmine Marbles does not cover code in Code Coverage report

When I use Jasmine marbles for unit testing margeMap and switchMap, those specific blocks don't cover in code coverage report. Is there a way to unit test margeMap and switchMap blocks so that they would be covered in code coverage report?
Sunny
  • 25
  • 1
  • 9
0
votes
1 answer

RxJS testing: marble test confusing case

I'm adding unit testing to my angular/rxjs project, and I'm using the marble test solution. And since I'm using the newer version of rxjs, so I used the build-in "TestScheduler" module. I'm following this post:…
Chris Bao
  • 2,418
  • 8
  • 35
  • 62
0
votes
1 answer

RxJS: why does subscribing makes no difference

Consider the following service example export class AuthService { private observableCache: { [key: string]: Observable } = {}; private resourceCache: { [key: string]: boolean } = {}; constructor(private userService: UserService) {…
Majesty
  • 2,097
  • 5
  • 24
  • 55
0
votes
1 answer

Is possible test one observable attribute in the service from component

I don't know if this that I want to do is possible, I have one component FiltersComponent and one Service FiltersService. In FiltersService I have one attribute onFilterChange of type BehaviorSubject. I expose it asObservable and I want to test when…
Rotceh
  • 99
  • 2
  • 14
0
votes
1 answer

Test code inside an rxjs subscription when using jasmine marbles

I want to be able to test the code that runs inside an observable subscription: function foo(someStream$: Observable) { someStream$.pipe( map((x) => x + 3), ).subscribe((result) => { SomeService.someFunc(result) }) } For…
Moo
  • 3,369
  • 4
  • 22
  • 41
0
votes
0 answers

How to properly test angular service stream

I'm trying to test a service data stream that looks something like this: loadHeader() { this.cbData.fetchHeader() .pipe( tap(header => console.log('FIRST: ', header)), withLatestFrom(this.user.userInfo$), …
J Price
  • 1
  • 3
0
votes
1 answer

How to test forkJoin() operator with jasmine-marbles

I created service which is sending data to back-end, data was filled by user in UI. User can also upload any file to send it to back-end too. I am trying to test this functionality with jasmine marbles. Here is my service code: export class…
Toms Tumshais
  • 333
  • 1
  • 5
  • 15
0
votes
1 answer

How to unit test cancellation of in-flight RXJS requests

I'm using NGRX, and use Effects to send HTTP requests. If a user sends another request, any previous request should be cancelled. It is working fine when I test manually, but I want to be able to unit test this. To test this, I'm mocking the service…
Boland
  • 1,531
  • 1
  • 14
  • 42
0
votes
1 answer

RxJS testing catch operator using Jasmine Marbles always fails

I'd like to test that if an observable catches a thrown error from inside one of its operators, I get the expected resulting observable. The service below returns an observable that throws an error or not depending on its error param. import {…
chihab
  • 31
  • 7
-1
votes
1 answer

Figure out rxjs marble tests in Angular

I would like to test a service with the help of marble tests. The basic service looks like this: interface User { name: string; } @Injectable({ providedIn: 'root', }) export class ServiceToTest { public get user$(): Observable
1 2 3 4 5
6