【发布时间】:2017-01-20 17:10:35
【问题描述】:
当我将 RxJS 从 5.0.0-rc.4 升级到 5.0.1 时,我的 HTTP 单元测试失败并显示 ..
超时订阅者
代码适用于 5.0.0-rc.4
这是失败的代码。任何想法表示赞赏。
private getHttpStream$(emit: any, url: string, httpResponseMapCallback: any, method: string) {
return this.http[method](url, emit, this.options)
.timeout(Config.http.timeout, new Error('timeout'))
.map((response: any) => {
if (response.status && !response.status.toString().startsWith(2)) {
return response;
}
// within the callback, emit provides access to the data emitted
return httpResponseMapCallback({emit, response});
})
.catch((err: any) => {
// Different code flow in real code v unit test code
/* istanbul ignore next */
if (err.status && err.statusText) {
return Observable.from([err]);
}
return Observable.from([err.message]);
});
}
【问题讨论】: