/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {AbstractType, Component, Directive, InjectFlags, InjectionToken, NgModule, Pipe, PlatformRef, SchemaMetadata, Type} from '@angular/core'; import {ComponentFixture} from './component_fixture'; import {MetadataOverride} from './metadata_override'; import {TestBed} from './test_bed'; /** * An abstract class for inserting the root test component element in a platform independent way. * * @publicApi */ export class TestComponentRenderer { insertRootElement(rootElementId: string) {} } /** * @publicApi */ export const ComponentFixtureAutoDetect = new InjectionToken('ComponentFixtureAutoDetect'); /** * @publicApi */ export const ComponentFixtureNoNgZone = new InjectionToken('ComponentFixtureNoNgZone'); /** * @publicApi */ export type TestModuleMetadata = { providers?: any[], declarations?: any[], imports?: any[], schemas?: Array, aotSummaries?: () => any[], }; /** * Static methods implemented by the `TestBedViewEngine` and `TestBedRender3` * * @publicApi */ export interface TestBedStatic { new(...args: any[]): TestBed; initTestEnvironment( ngModule: Type|Type[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed; /** * Reset the providers for the test injector. */ resetTestEnvironment(): void; resetTestingModule(): TestBedStatic; /** * Allows overriding default compiler providers and settings * which are defined in test_injector.js */ configureCompiler(config: {providers?: any[]; useJit?: boolean;}): TestBedStatic; /** * Allows overriding default providers, directives, pipes, modules of the test injector, * which are defined in test_injector.js */ configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic; /** * Compile components with a `templateUrl` for the test's NgModule. * It is necessary to call this function * as fetching urls is asynchronous. */ compileComponents(): Promise; overrideModule(ngModule: Type, override: MetadataOverride): TestBedStatic; overrideComponent(component: Type, override: MetadataOverride): TestBedStatic; overrideDirective(directive: Type, override: MetadataOverride): TestBedStatic; overridePipe(pipe: Type, override: MetadataOverride): TestBedStatic; overrideTemplate(component: Type, template: string): TestBedStatic; /** * Overrides the template of the given component, compiling the template * in the context of the TestingModule. * * Note: This works for JIT and AOTed components as well. */ overrideTemplateUsingTestingModule(component: Type, template: string): TestBedStatic; /** * Overwrites all providers for the given token with the given provider definition. * * Note: This works for JIT and AOTed components as well. */ overrideProvider(token: any, provider: { useFactory: Function, deps: any[], }): TestBedStatic; overrideProvider(token: any, provider: {useValue: any;}): TestBedStatic; overrideProvider(token: any, provider: { useFactory?: Function, useValue?: any, deps?: any[], }): TestBedStatic; inject( token: Type|InjectionToken|AbstractType, notFoundValue?: T, flags?: InjectFlags): T; inject( token: Type|InjectionToken|AbstractType, notFoundValue: null, flags?: InjectFlags): T |null; /** @deprecated from v9.0.0 use TestBed.inject */ get(token: Type|InjectionToken, notFoundValue?: T, flags?: InjectFlags): any; /** @deprecated from v9.0.0 use TestBed.inject */ get(token: any, notFoundValue?: any): any; createComponent(component: Type): ComponentFixture; }