diff --git a/spec/operators/timeout-spec.ts b/spec/operators/timeout-spec.ts index 184b63309e..ae5ca66941 100644 --- a/spec/operators/timeout-spec.ts +++ b/spec/operators/timeout-spec.ts @@ -25,14 +25,17 @@ describe('Observable.prototype.timeout', () => { it('should emit and error of an instanceof TimeoutError on timeout', () => { const e1 = cold('-------a--b--|'); const result = e1.timeout(50, rxTestScheduler); + let error; result.subscribe(() => { throw new Error('this should not next'); }, err => { - expect(err).to.be.an.instanceof(Rx.TimeoutError); + error = err; }, () => { throw new Error('this should not complete'); }); rxTestScheduler.flush(); + expect(error).to.be.an.instanceof(Rx.TimeoutError); + expect(error.name).to.equal('TimeoutError'); }); it('should not timeout if source completes within absolute timeout period', () => { diff --git a/src/internal/util/TimeoutError.ts b/src/internal/util/TimeoutError.ts index 506249e94d..11fda67697 100644 --- a/src/internal/util/TimeoutError.ts +++ b/src/internal/util/TimeoutError.ts @@ -8,7 +8,7 @@ export class TimeoutError extends Error { constructor() { super('Timeout has occurred'); - + this.name = 'TimeoutError'; (Object as any).setPrototypeOf(this, TimeoutError.prototype); } }