- Introduces `CompilerFactory` which can be part of a `PlatformRef`. - Introduces `WorkerAppModule`, `WorkerUiModule`, `ServerModule` - Introduces `serverDynamicPlatform` for applications using runtime compilation on the server. - Changes browser bootstrap for runtime and offline compilation (see below for an example). * introduces `bootstrapModule` and `bootstrapModuleFactory` in `@angular/core` * introduces new `browserDynamicPlatform` in `@angular/platform-browser-dynamic - Changes `initTestEnvironment` (which used to be `setBaseTestProviders`) to not take a compiler factory any more (see below for an example). BREAKING CHANGE: ## Migration from `setBaseTestProviders` to `initTestEnvironment`: - For the browser platform: BEFORE: ``` import {setBaseTestProviders} from ‘@angular/core/testing’; import {TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS} from ‘@angular/platform-browser-dynamic/testing’; setBaseTestProviders(TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); ``` AFTER: ``` import {initTestEnvironment} from ‘@angular/core/testing’; import {browserDynamicTestPlatform, BrowserDynamicTestModule} from ‘@angular/platform-browser-dynamic/testing’; initTestEnvironment( BrowserDynamicTestModule, browserDynamicTestPlatform()); ``` - For the server platform: BEFORE: ``` import {setBaseTestProviders} from ‘@angular/core/testing’; import {TEST_SERVER_PLATFORM_PROVIDERS, TEST_SERVER_APPLICATION_PROVIDERS} from ‘@angular/platform-server/testing/server’; setBaseTestProviders(TEST_SERVER_PLATFORM_PROVIDERS, TEST_SERVER_APPLICATION_PROVIDERS); ``` AFTER: ``` import {initTestEnvironment} from ‘@angular/core/testing’; import {serverTestPlatform, ServerTestModule} from ‘@angular/platform-browser-dynamic/testing’; initTestEnvironment( ServerTestModule, serverTestPlatform()); ``` ## Bootstrap changes ``` @AppModule({ modules: [BrowserModule], precompile: [MainComponent], providers: […], // additional providers directives: […], // additional platform directives pipes: […] // additional platform pipes }) class MyModule { constructor(appRef: ApplicationRef) { appRef.bootstrap(MainComponent); } } // offline compile import {browserPlatform} from ‘@angular/platform-browser’; import {bootstrapModuleFactory} from ‘@angular/core’; bootstrapModuleFactory(MyModuleNgFactory, browserPlatform()); // runtime compile long form import {browserDynamicPlatform} from ‘@angular/platform-browser-dynamic’; import {bootstrapModule} from ‘@angular/core’; bootstrapModule(MyModule, browserDynamicPlatform()); ``` Closes #9922 Part of #9726
172 lines
4.8 KiB
TypeScript
172 lines
4.8 KiB
TypeScript
/** @stable */
|
|
export declare function addProviders(providers: Array<any>): void;
|
|
|
|
/** @deprecated */
|
|
export declare var afterEach: Function;
|
|
|
|
/** @stable */
|
|
export declare function async(fn: Function): (done: any) => any;
|
|
|
|
/** @deprecated */
|
|
export declare var beforeEach: any;
|
|
|
|
/** @deprecated */
|
|
export declare function beforeEachProviders(fn: () => Array<any>): void;
|
|
|
|
/** @stable */
|
|
export declare class ComponentFixture<T> {
|
|
changeDetectorRef: ChangeDetectorRef;
|
|
componentInstance: T;
|
|
componentRef: ComponentRef<T>;
|
|
debugElement: DebugElement;
|
|
elementRef: ElementRef;
|
|
nativeElement: any;
|
|
ngZone: NgZone;
|
|
constructor(componentRef: ComponentRef<T>, ngZone: NgZone, autoDetect: boolean);
|
|
autoDetectChanges(autoDetect?: boolean): void;
|
|
checkNoChanges(): void;
|
|
destroy(): void;
|
|
detectChanges(checkNoChanges?: boolean): void;
|
|
isStable(): boolean;
|
|
whenStable(): Promise<any>;
|
|
}
|
|
|
|
/** @experimental */
|
|
export declare var ComponentFixtureAutoDetect: OpaqueToken;
|
|
|
|
/** @experimental */
|
|
export declare var ComponentFixtureNoNgZone: OpaqueToken;
|
|
|
|
/** @stable */
|
|
export declare function configureCompiler(config: {
|
|
providers?: any[];
|
|
useJit?: boolean;
|
|
}): void;
|
|
|
|
/** @stable */
|
|
export declare function configureModule(moduleDef: {
|
|
providers?: any[];
|
|
directives?: any[];
|
|
pipes?: any[];
|
|
precompile?: any[];
|
|
modules?: any[];
|
|
}): void;
|
|
|
|
/** @deprecated */
|
|
export declare var ddescribe: any;
|
|
|
|
/** @deprecated */
|
|
export declare var describe: Function;
|
|
|
|
/** @experimental */
|
|
export declare function discardPeriodicTasks(): void;
|
|
|
|
/** @deprecated */
|
|
export declare var expect: Function;
|
|
|
|
/** @experimental */
|
|
export declare function fakeAsync(fn: Function): (...args: any[]) => any;
|
|
|
|
/** @deprecated */
|
|
export declare var fdescribe: any;
|
|
|
|
/** @deprecated */
|
|
export declare var fit: any;
|
|
|
|
/** @experimental */
|
|
export declare function flushMicrotasks(): void;
|
|
|
|
/** @experimental */
|
|
export declare function getTestInjector(): TestInjector;
|
|
|
|
/** @deprecated */
|
|
export declare var iit: any;
|
|
|
|
/** @experimental */
|
|
export declare function initTestEnvironment(appModule: Type, platform: PlatformRef): void;
|
|
|
|
/** @stable */
|
|
export declare function inject(tokens: any[], fn: Function): () => any;
|
|
|
|
/** @experimental */
|
|
export declare class InjectSetupWrapper {
|
|
constructor(_moduleDef: () => {
|
|
providers?: any[];
|
|
directives?: any[];
|
|
pipes?: any[];
|
|
precompile?: any[];
|
|
modules?: any[];
|
|
});
|
|
inject(tokens: any[], fn: Function): () => any;
|
|
}
|
|
|
|
/** @deprecated */
|
|
export declare var it: any;
|
|
|
|
/** @experimental */
|
|
export declare function resetTestEnvironment(): void;
|
|
|
|
/** @stable */
|
|
export declare class TestComponentBuilder {
|
|
protected _injector: Injector;
|
|
constructor(_injector: Injector);
|
|
createAsync<T>(rootComponentType: ConcreteType<T>): Promise<ComponentFixture<T>>;
|
|
createFakeAsync<T>(rootComponentType: ConcreteType<T>): ComponentFixture<T>;
|
|
protected createFromFactory<C>(ngZone: NgZone, componentFactory: ComponentFactory<C>): ComponentFixture<C>;
|
|
createSync<T>(rootComponentType: ConcreteType<T>): ComponentFixture<T>;
|
|
overrideAnimations(componentType: Type, animations: AnimationEntryMetadata[]): TestComponentBuilder;
|
|
overrideDirective(componentType: Type, from: Type, to: Type): TestComponentBuilder;
|
|
overrideProviders(type: Type, providers: any[]): TestComponentBuilder;
|
|
overrideTemplate(componentType: Type, template: string): TestComponentBuilder;
|
|
overrideView(componentType: Type, view: ViewMetadata): TestComponentBuilder;
|
|
overrideViewProviders(type: Type, providers: any[]): TestComponentBuilder;
|
|
}
|
|
|
|
/** @experimental */
|
|
export declare class TestComponentRenderer {
|
|
insertRootElement(rootElementId: string): void;
|
|
}
|
|
|
|
/** @experimental */
|
|
export declare class TestInjector implements Injector {
|
|
appModule: Type;
|
|
platform: PlatformRef;
|
|
configureCompiler(config: {
|
|
providers?: any[];
|
|
useJit?: boolean;
|
|
}): void;
|
|
configureModule(moduleDef: {
|
|
providers?: any[];
|
|
directives?: any[];
|
|
pipes?: any[];
|
|
precompile?: any[];
|
|
modules?: any[];
|
|
}): void;
|
|
createInjectorAsync(): Promise<Injector>;
|
|
createInjectorSync(): Injector;
|
|
execute(tokens: any[], fn: Function): any;
|
|
get(token: any, notFoundValue?: any): any;
|
|
reset(): void;
|
|
}
|
|
|
|
/** @experimental */
|
|
export declare function tick(millis?: number): void;
|
|
|
|
/** @experimental */
|
|
export declare function withModule(moduleDef: () => {
|
|
providers?: any[];
|
|
directives?: any[];
|
|
pipes?: any[];
|
|
precompile?: any[];
|
|
modules?: any[];
|
|
}): InjectSetupWrapper;
|
|
|
|
/** @experimental */
|
|
export declare function withProviders(providers: () => any): InjectSetupWrapper;
|
|
|
|
/** @deprecated */
|
|
export declare var xdescribe: Function;
|
|
|
|
/** @deprecated */
|
|
export declare var xit: any;
|