You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Marble testing with throwError(undefined) should return an Observable with *.notification.error equals to the value passed into throwError constructor itself, but it's expected to a default string called 'error' currently.
Expected $[0].notification.error = undefined to equal 'error'.
// util.spec.tsimport{throwError}from'rxjs';import{TestScheduler}from'rxjs/testing';import{securedErrorHandler}from'./util';describe('securedErrorHandler',()=>{constexpectedMarbles='#';letscheduler: TestScheduler;beforeEach(()=>{scheduler=newTestScheduler((actual,expected)=>{expect(actual).toEqual(expected);});});it('#securedErrorHandler should construct an error if input error is not an instance of Observable',()=>{scheduler.run(({ expectObservable })=>{constresult$=securedErrorHandler(undefined);expectObservable(result$).toBe(expectedMarbles,null,undefined);});}}
It will set error value to 'error' when passed in errorValue is a falsy value. Is there any consideration about it, I think it should be removed or be documented in RxJs docs.
The text was updated successfully, but these errors were encountered:
hijiangtao
changed the title
throwError(undefined) is not equal to undefined in TestCheduler
throwError with a falsy value is not equal to undefined in Marble Testing with TestCheduler
Jul 2, 2020
Arg!!!! Why is there no action on this in 3 years?
I just ran into this same issue. I am trying to write a test with TestScheduler for a method that does this subscriber.error(). My test is really simple expectObservable(observable).toBe('#')
I have tried using expectObservable(observable).toBe('#', undefined, 'error') but that doesn't work. What does work is if I modify my code to subscriber.error('error') which is completely unacceptable.
Am I missing something here? Why is the TestScheduler setting a default value?
Bug Report
Current Behavior
Marble testing with
throwError(undefined)
should return an Observable with*.notification.error
equals to the value passed into throwError constructor itself, but it's expected to a default string called 'error' currently.Reproduction
My function to be test shows here:
The unit test file shows:
Expected behavior
Unit test should get passed.
Environment
Possible Solution
I found following logic in
rxjs/src/internal/testing/TestScheduler.ts
Line 353 in fd66c29
It will set error value to 'error' when passed in
errorValue
is a falsy value. Is there any consideration about it, I think it should be removed or be documented in RxJs docs.The text was updated successfully, but these errors were encountered: