Use when configuring tests for code that uses a LazyLoader.
Angular tests that use waitForAsync or fakeAsync depend on Zone.js to know when asynchronous actions are pending and when they complete. Zone is not aware of the dynamic imports used for lazy loading, so you can use this helper during test setup to work around the issue.
// if you have followed the pattern from LazyLoader docs and created // both a bundle and token, import the bundle directly into your test file importsnackBarBundlefrom'./snack-bar-bundle'; import { snackBarLoaderToken } from'./snack-bar-loader-token';
// add to the constructor of AngularContext or ComponentContext constctx = newAngularContext({ providers: [provideEagerLoading(snackBarLoaderToken, snackBarBundle)], });
// or if using TestBed directly, add to configureTestingModule TestBed.configureTestingModule({ providers: [provideEagerLoading(snackBarLoaderToken, snackBarBundle)], });
Use when configuring tests for code that uses a LazyLoader.
Angular tests that use waitForAsync or fakeAsync depend on Zone.js to know when asynchronous actions are pending and when they complete. Zone is not aware of the dynamic imports used for lazy loading, so you can use this helper during test setup to work around the issue.