Cam*_*ron 5 testing typescript angular angular-httpclient angular-httpclient-interceptors
我正在开发一个 Angular 10 应用程序,该应用程序使用HttpInterceptor向所有响应添加特定标头。不幸的是,在尝试测试此拦截器时,我不断收到以下错误:
Error: Expected one matching request for criteria "Match by function: ", found none.
Run Code Online (Sandbox Code Playgroud)
或类似的变体:
Error: Expected one matching request for criteria "Match URL: /endpoint", found none.
Run Code Online (Sandbox Code Playgroud)
我的期望是这个测试会通过,但我现在不知道为什么它不起作用。
这是我的拦截器:
Error: Expected one matching request for criteria "Match by function: ", found none.
Run Code Online (Sandbox Code Playgroud)
这是我的测试:
Error: Expected one matching request for criteria "Match URL: /endpoint", found none.
Run Code Online (Sandbox Code Playgroud)
也就是说,可能值得指出的是,我尝试应用以下资源中的解决方案但无济于事(大多数似乎与我已经拥有的类似,而且许多似乎适用于旧版本的 Angular):
HttpClient我所知道的。spyOn了http.get(...)在我的测试功能,导致被淘汰上面的错误,但它并没有叫我的intercept功能时,我这样做。非常感谢任何帮助 - 谢谢!
| 归档时间: |
|
| 查看次数: |
313 次 |
| 最近记录: |