填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

@angular/core/testing

Provides infrastructure for testing Angular core functionality.

入口點的匯出

類別

ComponentFixture

用於除錯和測試元件的夾具。

Fixture for debugging and testing a component.

InjectSetupWrapper
TestBed

配置和初始化用於單元測試的環境,並提供用於在單元測試中建立元件和服務的方法。

Configures and initializes environment for unit testing and provides methods for creating components and services in unit tests.

TestComponentRenderer

一個用於以與平臺無關的方式插入根測試元件元素的抽象類別。

An abstract class for inserting the root test component element in a platform independent way.

函式

async

已廢棄: use waitForAsync(), (expected removal in v12)

改用 waitForAsync()(將在 v12 中刪除)

discardPeriodicTasks

丟棄所有剩餘的定期任務。

Discard all remaining periodic tasks.

fakeAsync

包裝一個函式,以便在 fakeAsync Zone 中執行:

Wraps a function to be executed in the fakeAsync zone:

flush

透過清空巨集任務佇列直到其為空,來為 fakeAsync Zone 中的計時器模擬非同步時間流逝。返回的值是本應經過的毫秒數。

Simulates the asynchronous passage of time for the timers in the fakeAsync zone by draining the macrotask queue until it is empty. The returned value is the milliseconds of time that would have been elapsed.

flushMicrotasks

重新整理所有未完成的微任務。

Flush any pending microtasks.

inject

允許在 beforeEach()it() 中注入依賴項。

Allows injecting dependencies in beforeEach() and it().

resetFakeAsyncZone

清除共享的偽非同步 Zone 以進行測試。在全域性 beforeEach 中呼叫。

Clears out the shared fake async zone for a test. To be called in a global beforeEach.

tick

為 fakeAsync Zone 中的計時器模擬非同步時間流逝。

Simulates the asynchronous passage of time for the timers in the fakeAsync zone.

waitForAsync

把一個測試函式包裝進一個非同步測試 Zone。當該 Zone 中的所有非同步呼叫都已完成時,該測試將會自動完成。 可用於包裝 inject呼叫。

Wraps a test function in an asynchronous test zone. The test will automatically complete when all asynchronous calls within this zone are done. Can be used to wrap an injectcall.

withModule

結構

TestBedStatic

TestBedViewEngineTestBedRender3 實現的靜態方法

Static methods implemented by the TestBedViewEngine and TestBedRender3

型別

ComponentFixtureAutoDetect
ComponentFixtureNoNgZone
MetadataOverride

用於修改元資料的型別

Type used for modifications to metadata

TestModuleMetadata
getTestBed

返回適用的 TestBed 單例。

Returns a singleton of the applicable TestBed.