我有一个名为X()的服务
我的构造函数
constructor(private http: ApiService) { }
其中ApiService扩展了Http。
在我的spec文件中,我有一个测试
x.xx(payload).subscribe(() => {
alert("Hi");
});
此警报未执行,测试处于异步模式。
如果我将构造函数更改为
constructor(private http: Http) { }
它有效。
我尝试了什么?
使用提供程序用Http [not working]
替换ApiService提供者:[ {provide:ApiService,useClass:Http},]
2.手动更改私人变量[不工作]
x['http']=Http
*******************更新*************************** *****************
https://github.com/astronaut1712/ng2-http-intercept/blob/master/src/intercept.http.service.ts这是APIService