W3cubDocs

/Angular

@angular/core/testing

entry-point

Provides infrastructure for testing Angular core functionality.

Entry point exports

Classes

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.

Functions

async

Deprecated: use waitForAsync(), (expected removal in v12)

discardPeriodicTasks

Discard all remaining periodic tasks.

fakeAsync

Wraps a function to be executed in the fakeAsync zone:

  • Microtasks are manually executed by calling flushMicrotasks().
  • Timers are synchronous; tick() simulates the asynchronous passage of time.
flush

Flushes any pending microtasks and simulates the asynchronous passage of time for the timers in the fakeAsync zone by draining the macrotask queue until it is empty.

flushMicrotasks

Flush any pending microtasks.

getTestBed

Returns a singleton of the TestBed class.

inject

Allows injecting dependencies in beforeEach() and it(). Note: this function (imported from the @angular/core/testing package) can only be used to inject dependencies in tests. To inject dependencies in your application code, use the inject function from the @angular/core package instead.

resetFakeAsyncZone

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

tick

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

waitForAsync

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 inject call.

withModule

Structures

ModuleTeardownOptions

Configures the test module teardown behavior in TestBed.

TestBedStatic

Static methods implemented by the TestBed.

TestEnvironmentOptions
TestModuleMetadata

Types

ComponentFixtureAutoDetect
ComponentFixtureNoNgZone
MetadataOverride

Type used for modifications to metadata

© 2010–2023 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/core/testing