[英]Jasmine: how to test a Promise.then block?
我想測試一個場景,我必須調用 function(從私有只讀服務),其中有一個異步調用,然后一些變量正在更新等。 在我的 spec.ts 中,我試圖模擬 serviceFunction 調用,但看起來它甚至根本沒有進入 the.then 塊。 你們有任何教程/信息來測試這種情況下的 the.then ...
[英]Jasmine: how to test a Promise.then block?
我想測試一個場景,我必須調用 function(從私有只讀服務),其中有一個異步調用,然后一些變量正在更新等。 在我的 spec.ts 中,我試圖模擬 serviceFunction 調用,但看起來它甚至根本沒有進入 the.then 塊。 你們有任何教程/信息來測試這種情況下的 the.then ...
[英]Ng-template is null in angular unit test
我試圖驗證只要 dynamicValue 不是 null,DOM 就會加載 ng-template 並顯示正確的內容; 但是,每當我嘗試在 my.html 中找到 ng-template-element 時,它總是 null。 區域顯示選擇.component.html 區域顯示選擇.compon ...
[英]spec has no expectations when using expect within subscribe
我正在嘗試創建一個測試來驗證從我的服務中的 Observable 返回的值: 這是測試: 測試不斷返回: SPEC HAS NO EXPECTATIONS 值切換時應包含真實值然而,測試本身通過了。 我試過使用fakeAsync()和Flush()來清除任務隊列,我試過使用Done() funct ...
[英]by.css always returns null [jasmine unit test ]
我不知道為什么在我的 Angular 項目中,當我嘗試訪問 HTML 元素時,Jasmin 總是返回 null! 我也曾嘗試調用 'fixture.whenStable().then' 但它再次返回 null! ...
[英]Testing Cesium with Jasmine (angular typescript)
我有一個使用銫的 angular typescript 應用程序: 銫容器.component.ts 在cesium-container.component.spec.ts :我的隊友嘗試使用TestBed創建組件,我嘗試使用new CesiumContainerComponent ,但都失敗了: ...
[英]Angular unit testing directive
我正在嘗試對我的指令進行單元測試,看起來像這樣顯示密碼.directive.ts 然后我的show-password.directive.spec.ts 但是我的測試出錯了類型錯誤:無法讀取 null 的屬性(讀取“nativeElement”) 看起來元素 span 沒有創建,但在實際測試中一切正 ...
[英]Unit Test Angular Http Request with pipe
我必須對這個 observable 執行單元測試,其中發現 map 將數據轉換為所需的 我已經完成了以下測試它但是跳過了 map 之后的調用 這段代碼預計會被閱讀在此處輸入圖像描述 ...
[英]Create list of imports service provider on unit testing
我是 Angular 的新手,我有一個新團隊告訴我用 Angular 8 對一個舊項目實施單元測試。所以在調查之后,我決定使用 Karma + Jasmine,我創建了.spect.ts文檔這個: describe("CashFlowSalariesComponent", () => { l ...
[英]Error on focused tests in Karma and Angular (failOnSkippedTests)
這里有沒有人對 Angular 的 Karma 測試中的failOnSkippedTests: true標志有有效的解決方案? 我嘗試了https://github.com/karma-runner/karma/issues/3284之后的所有內容。 當我設置重點測試時,我跳過了測試,但仍然成功。 ...
[英]Jasmine angular unit testing BehaviorSubject
我有這樣的服務日歷域.service.ts 像這樣的單元測試日歷域.service.spec.ts 如您所見,我沒有測試這兩個 function,因為老實說我什至不知道如何開始測試,關於如何開始的任何信息,謝謝 ...
[英]Mock service return undefined with nested services
我目前正在處理一個 Angular 項目,我正在使用 Karma + Jasmine 為組件創建單元測試,所以我有 HTML,它有一個ngIf調用 API 服務: HTML *ngIf中的服務是我想在下面的spec.ts上模擬的服務 TS 斯佩克特 describe('CashFlowSalar ...
[英]How to mock RxJS Subject and call next method in Angular unit-test
我試圖模擬 RxJS 主題,它是服務的屬性。 此服務在 class 組件構造函數中作為依賴注入調用。 我有兩種方法storeProduct() && responseHandler()所以在 responseHandler 方法中我訂閱了這個主題。 所以我嘗試為這兩種方法編寫單元測試 ...
[英]Getting undefined on service called from html
我目前正在處理一個 Angular 項目,我正在使用 Karma + Jasmine 為組件創建單元測試,所以我有 HTML,它有一個ngIf調用 API 服務: HTML TS 斯佩克特 describe('CashFlowSalariesComponent', () => { let ...
[英]Spy on a field assignment using Jasmine
我如何使用 Jasmine 監視現場作業? 例如,我正在測試 object: 現在我想斷言testObj.testObjFunc會將"foo"分配給testObj.testObjField 。 我該如何進行? 這是我嘗試過的: 但我收到錯誤: 錯誤::屬性 testObjField 沒有設置訪問類型 ...
[英]Angular Unit testing : Error: Cannot match any routes
我正在我的 angular 15 應用程序下進行單元測試。 運行測試時出現以下錯誤: 錯誤:無法匹配任何路由。URL 段:'signin' 下面是我的組件的單元測試代碼: ...
[英]How to properly test statements in setInterval() in Angular?
我有這個非常簡單的代碼: 在我的單元測試中,僅包含 this.getAuthInfo() 的行未被視為涵蓋。 是否有可能以某種方式對此進行測試? 我用 jasmine.createSpy 嘗試了一些方法,但似乎沒有任何效果(很可能是因為我做錯了)。 有人可以幫我把它弄好嗎? 謝謝更新:我試過這樣的 ...
[英]Setup service provider on unit testing
我有一個組件如下: TS 現在我想為它創建一個單元測試,所以我嘗試 .spec.ts 但這是拋出一條錯誤消息: NullInjectorError:StaticInjectorError(DynamicTestModule)[CashFlowSalariesComponent -> Api ...
[英]DynamicTestModule throws error on angular unit testing
我目前正在使用 Karma 和 Jasmine 創建單元測試: 配置文件列表組件有很多子項,這就是我在declarations中導入它們的原因。 ProfilesFiltersComponent使用 angular Forms 作為: HTML: TS 因此,測試要求我提供表單組: 無法綁定到 ...
[英]How to automate testing function with click handler that have async await inside the function using karma-jasmine?
所以我正在嘗試測試異步運行 function 的按鈕。 這是我的按鈕邏輯。 這是我的測試 我正在使用 lit-element,只是它與 React 類似,我有自定義元素 <define-module>,里面有按鈕。 然后我給它所需的屬性,然后它就會呈現。 這是我的測試日志測試日志如您所 ...
[英]Cannot find module 'expect/build/jasmineUtils'
嘗試執行測試套件時,我發現了這個錯誤,即重新安裝所有與 jest 相關的依賴項並不能解決問題。 可能與它有關,看起來很相似: https://github.com/just-jeb/jest-marbles/issues/184 ...