![](/img/trans.png)
[英]How to use a DomSanitizer inside a unit test, if the component does not inject it?
我有一個簡單的組件,它不注入 DomSanitizer。 假設它是 如何在單元測試中使用 DomSanitizer? 我試過提供並注入它。 這是我的 spec.ts 文件: TypeError 說: TypeError: sanitizr.bypassSecurityTrustHtml is n ...
[英]How to use a DomSanitizer inside a unit test, if the component does not inject it?
我有一個簡單的組件,它不注入 DomSanitizer。 假設它是 如何在單元測試中使用 DomSanitizer? 我試過提供並注入它。 這是我的 spec.ts 文件: TypeError 說: TypeError: sanitizr.bypassSecurityTrustHtml is n ...
[英]Property 'configureTestingModule' doesn't exist on type TestBedStatic
我已使用ng update將我的 Angular 12 應用程序更新為 Angular 14 。 構建成功,可以看到我的應用程序運行良好,但我的測試失敗了。 我得到的錯誤之一是: 類型 TestBedStatic 上不存在屬性“configureTestingModule” 任何人都知道任何解決方 ...
[英]Jmeter thread time series with milliseconds frequency
我正在嘗試根據特定的線程時間序列在 JMeter 中構建測試計划。 例如,我知道在時間 x,有 n(x) 個用戶,在時間 x+t,有 n(x+t) 個用戶,以此類推。 問題是用戶數必須在 t ~= 500ms 內更新,線程數在 20 - 200 的范圍內。另外,理想情況下,我想為下一個時隙添加和刪除 ...
[英]Testing URL Params in Angular Unit Test
我正在嘗試測試 URL 參數中包含的字符串。 在我的 typescript 文件中,我有以下方法: 測試應確保當參數包含字符串“view”時,應禁用表單。 目前在我的規格文件中我有: 我已經看到了一些測試 URL 參數的不同方法的解決方案,但找不到在測試中模擬 URL 參數以包含“視圖”以禁用表單的 ...
[英]Is there a way to test Observable subscription in Angular?
我是 angular 的新手,試圖為下面的 function 編寫單元測試用例。 主頁組件.ts 我嘗試了下面的測試用例,但我不確定如何覆蓋YesNo , cols , getAllAccounts () HomeComponent.spec.ts Angular版本 Angular CLI: ...
[英]Default value on @Input causes test problems - angular, abstract class
我的測試遇到了一些問題。 就我而言,我有兩個組件: 我的測試是這樣的: 問題是@Input() foo = true; 在AComponent 。 默認值和ReactiveFormsModule肯定有問題。 錯誤顯示: 如果我刪除默認值,一切正常。 角度版本是 提前致謝! ...
[英]Failed to find firebase ui widget on page - Angular test environment
我正在為我的 angular web 應用程序編寫測試,該應用程序包含一個帶有 firebase UI 元素的頁面。 有兩種測試,一種確保頁面加載,另一種確保 firebaseUI 組件正確加載: authentication.component.spec.ts/*eslint-env jasmi ...
[英]JMeter: Performance testing of two different Thread Pools and their comparison
我的問題與此不同,因為它太舊了,可能有新的 JMeter 插件。 我有兩個 Java 類Server1和Server2 。 Server1 class 擴展了ThreadPoolExecutor 。 Server2 class 擴展了WaterMarkExecutor 用戶可以通過 Socket ...
[英]How to test property values receiving Observable from service
我想問一下測試從內聯服務接收數據的屬性的常見做法是什么。 我無法測試從服務定義的內聯值接收值的屬性。 這是我的財產 getInstitutions()和getDataSetTypes()返回Observable<string()> 這是我的規格 測試失敗,結果 我也增加了超時間隔,但沒 ...
[英]When exactly is compileComponents needed?
我正在將僅使用 jest 的組件單元測試遷移到使用 Testbed 和 jest 的 UI 測試(在我剛剛使用component = new MyCompontent()進行單元測試之前)。 我正在使用 Angular 11。 關於compileComponents我有一件事我不明白。 在文檔中它 ...
[英]Angular11 test: ReferenceError: ResizeObserver is not defined
我在我的組件中使用ResizeObserver並且它工作正常。 但是在運行 ut 時會出現這樣的錯誤: 我使用 TestBed 創建組件: 我不明白為什么會出現這個錯誤,我只是新了一個 object。 ts版本 謝謝你的幫助! ...
[英]What is the recommended approach to configure TestBed in Jasmine test cases in Angular?
我已經開始為 Angular 編寫測試用例,在從互聯網上閱讀文章時,我發現我們可以通過不同的方式配置我們的TestBed 。 下面是幾個例子: 示例 1: beforeEach(async(() => { TestBed.configureTestingModule({ ... ...
[英]How to reuse Mock dependencies in Angular Unit Test?
我在 Angular 中編寫單元測試,我是 mocking 重復所有規范中的所有服務,TestBed.configureTestingModule 在所有規范文件中具有相同的代碼。 是否可以將此 TestBed.configureTestingModule 和 Mock 依賴項移動到某個公共文件中 ...
[英]All Angular dependencies need to be forwardRefs or Jest Breaks
我在使用 Jest 和 Angular 時遇到了一些煩人的問題。 我完全不知道為什么,但是每次我嘗試注入最簡單的服務時,都會引起開玩笑的抱怨:FAIL apps/simplescrum/src/app/app.component.spec.ts ● AppComponent › should ...
[英]How to mock Injector instance in Angular / Jasmine tests?
我需要測試使用Injector而不是constructor()來注入服務的服務。 我使用這種方式的主要原因是大量服務擴展了我的常見SimpleDataService 。 這里有CompanyService 、 ProductService 、 TagService等,大家都擴展了SimpleDat ...
[英]Angular testing - Testing interdependent services
我是測試界的新手,如果這個問題太明顯了,很抱歉! 我有一個功能齊全且復雜的 angular 9 項目。 我將在這里簡單地解釋我的問題: 我有多種服務: Service_MAIN(使用 HttpClient、Router 等) Service_A(使用 Service_MAIN) Service ...
[英]TestBed.OverrideProvider() doesn't work if TestBed.inject() or TestBed.get() (deprecated) has run before
給定下面的示例規范測試 問題是測試失敗,因為默認值始終為真,隨機不是配置的屬性。 這意味着在配置測試模塊期間 config 仍然具有默認值,並且提供程序沒有被覆蓋。 知道為什么嗎? overrideProvider方法是否只是更新最初在 configureTestingModule 傳遞的modu ...
[英]NullInjectorError of feature store when testing component
我嘗試修復LoginComponent的測試。 當功能存儲(通知)組件從SharedModule移動到延遲加載的模塊時出現錯誤。 我不知道這里有什么問題。 我用 ngrx 測試了測試組件的許多配置。 此外,由於進行了強重構,移回NotificationModule (帶有功能存儲)並不能修復該錯誤 ...
[英]Unit testing a function with return value within subscribe
我有一個 function 要進行單元測試,但我不確定如何處理。 簡化: 在這種情況下,我想測試someFunction的結果。 但是,這不起作用: 在此塊之前已配置 ServiceSpy。 我可以看到函數已執行並返回 true。 但是,目前我要求result ,它仍然是未定義的。 測試框架不會等待 ...
[英]Angular How to update mock data in different unit tests
describe('landing component', () => { beforeEach(() => { mockAccountService = new Mock<AccountService>({ ...