passed along to TestBed.configureTestingModule(). Automatically includes HttpClientTestingModule for you.
Set this before calling run() to mock the time at which the test starts.
ProtectedcleanPerforms any cleanup needed at the end of each test. This base implementation calls discardPeriodicTasks and flush to avoid an error from the fakeAsync zone.
Returns whether any components match the given query.
ProtectedinitThis is a hook for subclasses to override. It is called during run(), before the test() callback. This implementation does nothing, but if you override this it is still recommended to call super.init() in case this implementation does something in the future.
Gets a service or other injectable from the root injector.
This implementation is a simple pass-through to TestBed.inject(), but subclasses may provide their own implementation. It is recommended to use this in your tests instead of using TestBed directly.
Returns whether this context is currently executing the #run callback.
Runs test in a fakeAsync zone. It can use async/await, but be sure anything you await is already due to execute (e.g. if a timeout is due in 3 seconds, call .tick(3000) before awaiting its result).
Also runs the following in this order, all within the same zone:
this.init()test()this.verifyPostTestConditions()this.cleanUp()ProtectedrunAdvance time and trigger change detection. It is common to call this with no arguments to trigger change detection without advancing time.
The unit of time amount represents. Accepts anything described in @s-libs/s-core's [TimeUnit]https://simontonsoftware.github.io/s-js-utils/typedoc/enums/timeunit.html enum.
ProtectedverifyRuns post-test verifications. This base implementation runs HttpTestingController.verify and MockErrorHandler.verify. Unlike #cleanUp, it is OK for this method to throw an error to indicate a violation.
StaticgetReturns the current AngularContext that is in use, or undefined if there is not one. A context is defined to be "in use" from the time it is constructed until after its run() method completes.
Provides the foundation for an opinionated testing pattern.
fakeAsynczone. This gives you full control over the timing of everything by default.This example tests a simple service that uses
HttpClient, and is tested by usingAngularContextdirectly. More oftenAngularContextwill be used as a super class. See ComponentContext for more common use cases.