![](/img/trans.png)
[英]spy on method when unit testing http interceptor in angular
我正在嘗試對 http 攔截器進行單元測試。 攔截器用於授權。 我可以測試基本的成功案例,但我現在正在嘗試測試 API 調用失敗的案例,因為訪問令牌已過期。 我的問題是,如何監視 AuthInterceptorService.getNewTokenAndRetryRequest() 方法? 我的攔截 ...
[英]spy on method when unit testing http interceptor in angular
我正在嘗試對 http 攔截器進行單元測試。 攔截器用於授權。 我可以測試基本的成功案例,但我現在正在嘗試測試 API 調用失敗的案例,因為訪問令牌已過期。 我的問題是,如何監視 AuthInterceptorService.getNewTokenAndRetryRequest() 方法? 我的攔截 ...
[英]How to test a method with multi-http calls
如何使用httpTestingController測試findArtists方法? 因此,理想情況下,該服務所做的是在第一次 get 調用時獲取一些藝術家的數據,但返回的數據並不包含在模板中顯示所需的所有數據。 因此,這就是我在 switchMap 中映射更多 HTTP 調用的原因,因為這些后續調用 ...
[英]Angular HttpTestingController Unable to match url with params
我是 HttpTesting 控制器的新手。 我的期望不起作用,因為 url 包含 HttpParams。 這是我的服務和 spec.ts 我收到以下錯誤: ...
[英]How to test multiple requests in pipeline in Angular?
我想測試在管道內完成的 3 個請求。 簡化示例: httpClient.get<Data[]>(testUrl) .pipe( mergeMap(() => range(0, 2)), mergeMap(() => http ...
[英]How can I test http request params in Angular?
當我發出 http 請求時,我正在嘗試測試 http 參數是否正確。 當我expect(req.request.params.get('action')).toEqual('pause'); 測試失敗: 預期:“暫停”收到:null 服務constructor(private _http: Htt ...
[英]Angular unit test - testing retryWhen in HttpInterceptor
我正在嘗試在 http 攔截器中測試 retryWhen 運算符,但是在嘗試多次重復我的服務調用時出現錯誤: “錯誤:預期有一個對標准“匹配 URL: http://someurl/tesdata ”的匹配請求,但沒有找到。” 所以我有2個問題。 首先,我是否要以正確的方式進行測試,其次,為什么 ...
[英]Angular 8 Jasmine not matching HTTP request
我有一個 Angular 服務發出一些 HTTP 請求,我想測試它是否使它們正確。 在它的依賴項中,它還有一個EnvironmentService ,它根據環境返回正確的 API 端點,我用 Jasmine 進行了模擬。 我的測試如下所示: 這是我的ShipmentsService方法: 我錯過了什 ...
[英]Test case for a service method which contains a HTTP subscribe - Angular HTTP RxJs
我有一個服務方法,它有一個服務調用(HTTP調用),它立即訂閱,並根據響應代碼執行其余的action命令。 示例:服務方法 我嘗試了以下示例(測試用例) 請協助我處理這種情況。 ...