UNPKG

31.8 kBTypeScriptView Raw
1/**
2 * @license Angular v12.0.5
3 * (c) 2010-2021 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { ChangeDetectorRef } from '@angular/core';
8import { Compiler } from '@angular/core';
9import { CompilerOptions } from '@angular/core';
10import { Component } from '@angular/core';
11import { ComponentFactory } from '@angular/core';
12import { ComponentRef } from '@angular/core';
13import { DebugElement } from '@angular/core';
14import { Directive } from '@angular/core';
15import { ElementRef } from '@angular/core';
16import { InjectFlags } from '@angular/core';
17import { InjectionToken } from '@angular/core';
18import { Injector } from '@angular/core';
19import { NgModule } from '@angular/core';
20import { NgZone } from '@angular/core';
21import { Pipe } from '@angular/core';
22import { PlatformRef } from '@angular/core';
23import { ProviderToken } from '@angular/core';
24import { SchemaMetadata } from '@angular/core';
25import { Type } from '@angular/core';
26
27/**
28 * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
29 * investigation.
30 *
31 * A work around is to mark it as `@codeGenApi` for now and investigate later.
32 *
33 * @codeGenApi
34 */
35export declare const __core_private_testing_placeholder__ = "";
36
37/**
38 * @deprecated use `waitForAsync()`, (expected removal in v12)
39 * @see {@link waitForAsync}
40 * @publicApi
41 * */
42export declare function async(fn: Function): (done: any) => any;
43
44/**
45 * Fixture for debugging and testing a component.
46 *
47 * @publicApi
48 */
49export declare class ComponentFixture<T> {
50 componentRef: ComponentRef<T>;
51 ngZone: NgZone | null;
52 private _autoDetect;
53 /**
54 * The DebugElement associated with the root element of this component.
55 */
56 debugElement: DebugElement;
57 /**
58 * The instance of the root component class.
59 */
60 componentInstance: T;
61 /**
62 * The native element at the root of the component.
63 */
64 nativeElement: any;
65 /**
66 * The ElementRef for the element at the root of the component.
67 */
68 elementRef: ElementRef;
69 /**
70 * The ChangeDetectorRef for the component
71 */
72 changeDetectorRef: ChangeDetectorRef;
73 private _renderer;
74 private _isStable;
75 private _isDestroyed;
76 private _resolve;
77 private _promise;
78 private _onUnstableSubscription;
79 private _onStableSubscription;
80 private _onMicrotaskEmptySubscription;
81 private _onErrorSubscription;
82 constructor(componentRef: ComponentRef<T>, ngZone: NgZone | null, _autoDetect: boolean);
83 private _tick;
84 /**
85 * Trigger a change detection cycle for the component.
86 */
87 detectChanges(checkNoChanges?: boolean): void;
88 /**
89 * Do a change detection run to make sure there were no changes.
90 */
91 checkNoChanges(): void;
92 /**
93 * Set whether the fixture should autodetect changes.
94 *
95 * Also runs detectChanges once so that any existing change is detected.
96 */
97 autoDetectChanges(autoDetect?: boolean): void;
98 /**
99 * Return whether the fixture is currently stable or has async tasks that have not been completed
100 * yet.
101 */
102 isStable(): boolean;
103 /**
104 * Get a promise that resolves when the fixture is stable.
105 *
106 * This can be used to resume testing after events have triggered asynchronous activity or
107 * asynchronous change detection.
108 */
109 whenStable(): Promise<any>;
110 private _getRenderer;
111 /**
112 * Get a promise that resolves when the ui state is stable following animations.
113 */
114 whenRenderingDone(): Promise<any>;
115 /**
116 * Trigger component destruction.
117 */
118 destroy(): void;
119}
120
121/**
122 * @publicApi
123 */
124export declare const ComponentFixtureAutoDetect: InjectionToken<boolean[]>;
125
126/**
127 * @publicApi
128 */
129export declare const ComponentFixtureNoNgZone: InjectionToken<boolean[]>;
130
131/**
132 * Discard all remaining periodic tasks.
133 *
134 * @publicApi
135 */
136export declare function discardPeriodicTasks(): void;
137
138/**
139 * Wraps a function to be executed in the `fakeAsync` zone:
140 * - Microtasks are manually executed by calling `flushMicrotasks()`.
141 * - Timers are synchronous; `tick()` simulates the asynchronous passage of time.
142 *
143 * If there are any pending timers at the end of the function, an exception is thrown.
144 *
145 * Can be used to wrap `inject()` calls.
146 *
147 * @param fn The function that you want to wrap in the `fakeAysnc` zone.
148 *
149 * @usageNotes
150 * ### Example
151 *
152 * {@example core/testing/ts/fake_async.ts region='basic'}
153 *
154 *
155 * @returns The function wrapped to be executed in the `fakeAsync` zone.
156 * Any arguments passed when calling this returned function will be passed through to the `fn`
157 * function in the parameters when it is called.
158 *
159 * @publicApi
160 */
161export declare function fakeAsync(fn: Function): (...args: any[]) => any;
162
163/**
164 * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone by
165 * draining the macrotask queue until it is empty.
166 *
167 * @param maxTurns The maximum number of times the scheduler attempts to clear its queue before
168 * throwing an error.
169 * @returns The simulated time elapsed, in milliseconds.
170 *
171 * @publicApi
172 */
173export declare function flush(maxTurns?: number): number;
174
175/**
176 * Flush any pending microtasks.
177 *
178 * @publicApi
179 */
180export declare function flushMicrotasks(): void;
181
182/**
183 * Returns a singleton of the applicable `TestBed`.
184 *
185 * It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
186 *
187 * @publicApi
188 */
189export declare const getTestBed: () => TestBed;
190
191/**
192 * Allows injecting dependencies in `beforeEach()` and `it()`.
193 *
194 * Example:
195 *
196 * ```
197 * beforeEach(inject([Dependency, AClass], (dep, object) => {
198 * // some code that uses `dep` and `object`
199 * // ...
200 * }));
201 *
202 * it('...', inject([AClass], (object) => {
203 * object.doSomething();
204 * expect(...);
205 * })
206 * ```
207 *
208 * @publicApi
209 */
210export declare function inject(tokens: any[], fn: Function): () => any;
211
212/**
213 * @publicApi
214 */
215export declare class InjectSetupWrapper {
216 private _moduleDef;
217 constructor(_moduleDef: () => TestModuleMetadata);
218 private _addModule;
219 inject(tokens: any[], fn: Function): () => any;
220}
221
222
223/**
224 * Type used for modifications to metadata
225 *
226 * @publicApi
227 */
228export declare type MetadataOverride<T> = {
229 add?: Partial<T>;
230 remove?: Partial<T>;
231 set?: Partial<T>;
232};
233
234/**
235 * Clears out the shared fake async zone for a test.
236 * To be called in a global `beforeEach`.
237 *
238 * @publicApi
239 */
240export declare function resetFakeAsyncZone(): void;
241
242/**
243 * @publicApi
244 */
245export declare interface TestBed {
246 platform: PlatformRef;
247 ngModule: Type<any> | Type<any>[];
248 /**
249 * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
250 * angular module. These are common to every test in the suite.
251 *
252 * This may only be called once, to set up the common providers for the current test
253 * suite on the current platform. If you absolutely need to change the providers,
254 * first use `resetTestEnvironment`.
255 *
256 * Test modules and platforms for individual platforms are available from
257 * '@angular/<platform_name>/testing'.
258 */
259 initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
260 /**
261 * Reset the providers for the test injector.
262 */
263 resetTestEnvironment(): void;
264 resetTestingModule(): void;
265 configureCompiler(config: {
266 providers?: any[];
267 useJit?: boolean;
268 }): void;
269 configureTestingModule(moduleDef: TestModuleMetadata): void;
270 compileComponents(): Promise<any>;
271 inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
272 inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
273 /** @deprecated from v9.0.0 use TestBed.inject */
274 get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
275 /** @deprecated from v9.0.0 use TestBed.inject */
276 get(token: any, notFoundValue?: any): any;
277 execute(tokens: any[], fn: Function, context?: any): any;
278 overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): void;
279 overrideComponent(component: Type<any>, override: MetadataOverride<Component>): void;
280 overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): void;
281 overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): void;
282 /**
283 * Overwrites all providers for the given token with the given provider definition.
284 */
285 overrideProvider(token: any, provider: {
286 useFactory: Function;
287 deps: any[];
288 }): void;
289 overrideProvider(token: any, provider: {
290 useValue: any;
291 }): void;
292 overrideProvider(token: any, provider: {
293 useFactory?: Function;
294 useValue?: any;
295 deps?: any[];
296 }): void;
297 overrideTemplateUsingTestingModule(component: Type<any>, template: string): void;
298 createComponent<T>(component: Type<T>): ComponentFixture<T>;
299}
300
301/**
302 * @description
303 * Configures and initializes environment for unit testing and provides methods for
304 * creating components and services in unit tests.
305 *
306 * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
307 *
308 * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
309 * according to the compiler used.
310 *
311 * @publicApi
312 */
313export declare const TestBed: TestBedStatic;
314
315/**
316 * Static methods implemented by the `TestBedViewEngine` and `TestBedRender3`
317 *
318 * @publicApi
319 */
320export declare interface TestBedStatic {
321 new (...args: any[]): TestBed;
322 initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed;
323 /**
324 * Reset the providers for the test injector.
325 */
326 resetTestEnvironment(): void;
327 resetTestingModule(): TestBedStatic;
328 /**
329 * Allows overriding default compiler providers and settings
330 * which are defined in test_injector.js
331 */
332 configureCompiler(config: {
333 providers?: any[];
334 useJit?: boolean;
335 }): TestBedStatic;
336 /**
337 * Allows overriding default providers, directives, pipes, modules of the test injector,
338 * which are defined in test_injector.js
339 */
340 configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic;
341 /**
342 * Compile components with a `templateUrl` for the test's NgModule.
343 * It is necessary to call this function
344 * as fetching urls is asynchronous.
345 */
346 compileComponents(): Promise<any>;
347 overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBedStatic;
348 overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBedStatic;
349 overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBedStatic;
350 overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBedStatic;
351 overrideTemplate(component: Type<any>, template: string): TestBedStatic;
352 /**
353 * Overrides the template of the given component, compiling the template
354 * in the context of the TestingModule.
355 *
356 * Note: This works for JIT and AOTed components as well.
357 */
358 overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBedStatic;
359 /**
360 * Overwrites all providers for the given token with the given provider definition.
361 *
362 * Note: This works for JIT and AOTed components as well.
363 */
364 overrideProvider(token: any, provider: {
365 useFactory: Function;
366 deps: any[];
367 }): TestBedStatic;
368 overrideProvider(token: any, provider: {
369 useValue: any;
370 }): TestBedStatic;
371 overrideProvider(token: any, provider: {
372 useFactory?: Function;
373 useValue?: any;
374 deps?: any[];
375 }): TestBedStatic;
376 inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
377 inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
378 /** @deprecated from v9.0.0 use TestBed.inject */
379 get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
380 /** @deprecated from v9.0.0 use TestBed.inject */
381 get(token: any, notFoundValue?: any): any;
382 createComponent<T>(component: Type<T>): ComponentFixture<T>;
383}
384
385/**
386 * An abstract class for inserting the root test component element in a platform independent way.
387 *
388 * @publicApi
389 */
390export declare class TestComponentRenderer {
391 insertRootElement(rootElementId: string): void;
392}
393
394/**
395 * @publicApi
396 */
397export declare type TestModuleMetadata = {
398 providers?: any[];
399 declarations?: any[];
400 imports?: any[];
401 schemas?: Array<SchemaMetadata | any[]>;
402 aotSummaries?: () => any[];
403};
404
405/**
406 * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
407 *
408 * The microtasks queue is drained at the very start of this function and after any timer callback
409 * has been executed.
410 *
411 * @param millis The number of milliseconds to advance the virtual timer.
412 * @param tickOptions The options to pass to the `tick()` function.
413 *
414 * @usageNotes
415 *
416 * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
417 * which determines whether or not to invoke new macroTasks.
418 *
419 * If you provide a `tickOptions` object, but do not specify a
420 * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
421 * then `processNewMacroTasksSynchronously` defaults to true.
422 *
423 * If you omit the `tickOptions` parameter (`tick(100))`), then
424 * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
425 *
426 * ### Example
427 *
428 * {@example core/testing/ts/fake_async.ts region='basic'}
429 *
430 * The following example includes a nested timeout (new macroTask), and
431 * the `tickOptions` parameter is allowed to default. In this case,
432 * `processNewMacroTasksSynchronously` defaults to true, and the nested
433 * function is executed on each tick.
434 *
435 * ```
436 * it ('test with nested setTimeout', fakeAsync(() => {
437 * let nestedTimeoutInvoked = false;
438 * function funcWithNestedTimeout() {
439 * setTimeout(() => {
440 * nestedTimeoutInvoked = true;
441 * });
442 * };
443 * setTimeout(funcWithNestedTimeout);
444 * tick();
445 * expect(nestedTimeoutInvoked).toBe(true);
446 * }));
447 * ```
448 *
449 * In the following case, `processNewMacroTasksSynchronously` is explicitly
450 * set to false, so the nested timeout function is not invoked.
451 *
452 * ```
453 * it ('test with nested setTimeout', fakeAsync(() => {
454 * let nestedTimeoutInvoked = false;
455 * function funcWithNestedTimeout() {
456 * setTimeout(() => {
457 * nestedTimeoutInvoked = true;
458 * });
459 * };
460 * setTimeout(funcWithNestedTimeout);
461 * tick(0, {processNewMacroTasksSynchronously: false});
462 * expect(nestedTimeoutInvoked).toBe(false);
463 * }));
464 * ```
465 *
466 *
467 * @publicApi
468 */
469export declare function tick(millis?: number, tickOptions?: {
470 processNewMacroTasksSynchronously: boolean;
471}): void;
472
473
474/**
475 * Wraps a test function in an asynchronous test zone. The test will automatically
476 * complete when all asynchronous calls within this zone are done. Can be used
477 * to wrap an {@link inject} call.
478 *
479 * Example:
480 *
481 * ```
482 * it('...', waitForAsync(inject([AClass], (object) => {
483 * object.doSomething.then(() => {
484 * expect(...);
485 * })
486 * });
487 * ```
488 *
489 * @publicApi
490 */
491export declare function waitForAsync(fn: Function): (done: any) => any;
492
493/**
494 * @publicApi
495 */
496export declare function withModule(moduleDef: TestModuleMetadata): InjectSetupWrapper;
497
498export declare function withModule(moduleDef: TestModuleMetadata, fn: Function): () => any;
499
500/**
501 * @description
502 * Configures and initializes environment for unit testing and provides methods for
503 * creating components and services in unit tests.
504 *
505 * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
506 *
507 * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
508 * according to the compiler used.
509 */
510export declare class ɵangular_packages_core_testing_testing_a implements TestBed {
511 /**
512 * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
513 * angular module. These are common to every test in the suite.
514 *
515 * This may only be called once, to set up the common providers for the current test
516 * suite on the current platform. If you absolutely need to change the providers,
517 * first use `resetTestEnvironment`.
518 *
519 * Test modules and platforms for individual platforms are available from
520 * '@angular/<platform_name>/testing'.
521 */
522 static initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): ɵangular_packages_core_testing_testing_a;
523 /**
524 * Reset the providers for the test injector.
525 */
526 static resetTestEnvironment(): void;
527 static resetTestingModule(): TestBedStatic;
528 /**
529 * Allows overriding default compiler providers and settings
530 * which are defined in test_injector.js
531 */
532 static configureCompiler(config: {
533 providers?: any[];
534 useJit?: boolean;
535 }): TestBedStatic;
536 /**
537 * Allows overriding default providers, directives, pipes, modules of the test injector,
538 * which are defined in test_injector.js
539 */
540 static configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic;
541 /**
542 * Compile components with a `templateUrl` for the test's NgModule.
543 * It is necessary to call this function
544 * as fetching urls is asynchronous.
545 */
546 static compileComponents(): Promise<any>;
547 static overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBedStatic;
548 static overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBedStatic;
549 static overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBedStatic;
550 static overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBedStatic;
551 static overrideTemplate(component: Type<any>, template: string): TestBedStatic;
552 /**
553 * Overrides the template of the given component, compiling the template
554 * in the context of the TestingModule.
555 *
556 * Note: This works for JIT and AOTed components as well.
557 */
558 static overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBedStatic;
559 /**
560 * Overwrites all providers for the given token with the given provider definition.
561 *
562 * Note: This works for JIT and AOTed components as well.
563 */
564 static overrideProvider(token: any, provider: {
565 useFactory: Function;
566 deps: any[];
567 }): TestBedStatic;
568 static overrideProvider(token: any, provider: {
569 useValue: any;
570 }): TestBedStatic;
571 static inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
572 static inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
573 /** @deprecated from v9.0.0 use TestBed.inject */
574 static get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
575 /**
576 * @deprecated from v9.0.0 use TestBed.inject
577 * @suppress {duplicate}
578 */
579 static get(token: any, notFoundValue?: any): any;
580 static createComponent<T>(component: Type<T>): ComponentFixture<T>;
581 private _instantiated;
582 private _compiler;
583 private _moduleRef;
584 private _moduleFactory;
585 private _compilerOptions;
586 private _moduleOverrides;
587 private _componentOverrides;
588 private _directiveOverrides;
589 private _pipeOverrides;
590 private _providers;
591 private _declarations;
592 private _imports;
593 private _schemas;
594 private _activeFixtures;
595 private _testEnvAotSummaries;
596 private _aotSummaries;
597 private _templateOverrides;
598 private _isRoot;
599 private _rootProviderOverrides;
600 platform: PlatformRef;
601 ngModule: Type<any> | Type<any>[];
602 /**
603 * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
604 * angular module. These are common to every test in the suite.
605 *
606 * This may only be called once, to set up the common providers for the current test
607 * suite on the current platform. If you absolutely need to change the providers,
608 * first use `resetTestEnvironment`.
609 *
610 * Test modules and platforms for individual platforms are available from
611 * '@angular/<platform_name>/testing'.
612 */
613 initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
614 /**
615 * Reset the providers for the test injector.
616 */
617 resetTestEnvironment(): void;
618 resetTestingModule(): void;
619 configureCompiler(config: {
620 providers?: any[];
621 useJit?: boolean;
622 }): void;
623 configureTestingModule(moduleDef: TestModuleMetadata): void;
624 compileComponents(): Promise<any>;
625 private _initIfNeeded;
626 private _createCompilerAndModule;
627 private _assertNotInstantiated;
628 inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
629 inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
630 /** @deprecated from v9.0.0 use TestBed.inject */
631 get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
632 /** @deprecated from v9.0.0 use TestBed.inject */
633 get(token: any, notFoundValue?: any): any;
634 execute(tokens: any[], fn: Function, context?: any): any;
635 overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): void;
636 overrideComponent(component: Type<any>, override: MetadataOverride<Component>): void;
637 overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): void;
638 overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): void;
639 /**
640 * Overwrites all providers for the given token with the given provider definition.
641 */
642 overrideProvider(token: any, provider: {
643 useFactory: Function;
644 deps: any[];
645 }): void;
646 overrideProvider(token: any, provider: {
647 useValue: any;
648 }): void;
649 private overrideProviderImpl;
650 overrideTemplateUsingTestingModule(component: Type<any>, template: string): void;
651 createComponent<T>(component: Type<T>): ComponentFixture<T>;
652}
653
654/**
655 * @description
656 * Configures and initializes environment for unit testing and provides methods for
657 * creating components and services in unit tests.
658 *
659 * TestBed is the primary api for writing unit tests for Angular applications and libraries.
660 *
661 * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
662 * according to the compiler used.
663 */
664export declare class ɵangular_packages_core_testing_testing_b implements TestBed {
665 /**
666 * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
667 * angular module. These are common to every test in the suite.
668 *
669 * This may only be called once, to set up the common providers for the current test
670 * suite on the current platform. If you absolutely need to change the providers,
671 * first use `resetTestEnvironment`.
672 *
673 * Test modules and platforms for individual platforms are available from
674 * '@angular/<platform_name>/testing'.
675 *
676 * @publicApi
677 */
678 static initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): TestBed;
679 /**
680 * Reset the providers for the test injector.
681 *
682 * @publicApi
683 */
684 static resetTestEnvironment(): void;
685 static configureCompiler(config: {
686 providers?: any[];
687 useJit?: boolean;
688 }): TestBedStatic;
689 /**
690 * Allows overriding default providers, directives, pipes, modules of the test injector,
691 * which are defined in test_injector.js
692 */
693 static configureTestingModule(moduleDef: TestModuleMetadata): TestBedStatic;
694 /**
695 * Compile components with a `templateUrl` for the test's NgModule.
696 * It is necessary to call this function
697 * as fetching urls is asynchronous.
698 */
699 static compileComponents(): Promise<any>;
700 static overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): TestBedStatic;
701 static overrideComponent(component: Type<any>, override: MetadataOverride<Component>): TestBedStatic;
702 static overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): TestBedStatic;
703 static overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): TestBedStatic;
704 static overrideTemplate(component: Type<any>, template: string): TestBedStatic;
705 /**
706 * Overrides the template of the given component, compiling the template
707 * in the context of the TestingModule.
708 *
709 * Note: This works for JIT and AOTed components as well.
710 */
711 static overrideTemplateUsingTestingModule(component: Type<any>, template: string): TestBedStatic;
712 static overrideProvider(token: any, provider: {
713 useFactory: Function;
714 deps: any[];
715 }): TestBedStatic;
716 static overrideProvider(token: any, provider: {
717 useValue: any;
718 }): TestBedStatic;
719 static inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
720 static inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
721 /** @deprecated from v9.0.0 use TestBed.inject */
722 static get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
723 /** @deprecated from v9.0.0 use TestBed.inject */
724 static get(token: any, notFoundValue?: any): any;
725 static createComponent<T>(component: Type<T>): ComponentFixture<T>;
726 static resetTestingModule(): TestBedStatic;
727 platform: PlatformRef;
728 ngModule: Type<any> | Type<any>[];
729 private _compiler;
730 private _testModuleRef;
731 private _activeFixtures;
732 private _globalCompilationChecked;
733 /**
734 * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
735 * angular module. These are common to every test in the suite.
736 *
737 * This may only be called once, to set up the common providers for the current test
738 * suite on the current platform. If you absolutely need to change the providers,
739 * first use `resetTestEnvironment`.
740 *
741 * Test modules and platforms for individual platforms are available from
742 * '@angular/<platform_name>/testing'.
743 *
744 * @publicApi
745 */
746 initTestEnvironment(ngModule: Type<any> | Type<any>[], platform: PlatformRef, aotSummaries?: () => any[]): void;
747 /**
748 * Reset the providers for the test injector.
749 *
750 * @publicApi
751 */
752 resetTestEnvironment(): void;
753 resetTestingModule(): void;
754 configureCompiler(config: {
755 providers?: any[];
756 useJit?: boolean;
757 }): void;
758 configureTestingModule(moduleDef: TestModuleMetadata): void;
759 compileComponents(): Promise<any>;
760 inject<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
761 inject<T>(token: ProviderToken<T>, notFoundValue: null, flags?: InjectFlags): T | null;
762 /** @deprecated from v9.0.0 use TestBed.inject */
763 get<T>(token: ProviderToken<T>, notFoundValue?: T, flags?: InjectFlags): any;
764 /** @deprecated from v9.0.0 use TestBed.inject */
765 get(token: any, notFoundValue?: any): any;
766 execute(tokens: any[], fn: Function, context?: any): any;
767 overrideModule(ngModule: Type<any>, override: MetadataOverride<NgModule>): void;
768 overrideComponent(component: Type<any>, override: MetadataOverride<Component>): void;
769 overrideTemplateUsingTestingModule(component: Type<any>, template: string): void;
770 overrideDirective(directive: Type<any>, override: MetadataOverride<Directive>): void;
771 overridePipe(pipe: Type<any>, override: MetadataOverride<Pipe>): void;
772 /**
773 * Overwrites all providers for the given token with the given provider definition.
774 */
775 overrideProvider(token: any, provider: {
776 useFactory?: Function;
777 useValue?: any;
778 deps?: any[];
779 }): void;
780 createComponent<T>(type: Type<T>): ComponentFixture<T>;
781 private assertNotInstantiated;
782 /**
783 * Check whether the module scoping queue should be flushed, and flush it if needed.
784 *
785 * When the TestBed is reset, it clears the JIT module compilation queue, cancelling any
786 * in-progress module compilation. This creates a potential hazard - the very first time the
787 * TestBed is initialized (or if it's reset without being initialized), there may be pending
788 * compilations of modules declared in global scope. These compilations should be finished.
789 *
790 * To ensure that globally declared modules have their components scoped properly, this function
791 * is called whenever TestBed is initialized or reset. The _first_ time that this happens, prior
792 * to any other operations, the scoping queue is flushed.
793 */
794 private checkGlobalCompilationFinished;
795 private destroyActiveFixtures;
796}
797
798export declare function ɵangular_packages_core_testing_testing_c(): ɵangular_packages_core_testing_testing_b;
799
800export declare class ɵMetadataOverrider {
801 private _references;
802 /**
803 * Creates a new instance for the given metadata class
804 * based on an old instance and overrides.
805 */
806 overrideMetadata<C extends T, T>(metadataClass: {
807 new (options: T): C;
808 }, oldMetadata: C, override: MetadataOverride<T>): C;
809}
810
811/**
812 * Special interface to the compiler only used by testing
813 *
814 * @publicApi
815 */
816export declare class ɵTestingCompiler extends Compiler {
817 get injector(): Injector;
818 overrideModule(module: Type<any>, overrides: MetadataOverride<NgModule>): void;
819 overrideDirective(directive: Type<any>, overrides: MetadataOverride<Directive>): void;
820 overrideComponent(component: Type<any>, overrides: MetadataOverride<Component>): void;
821 overridePipe(directive: Type<any>, overrides: MetadataOverride<Pipe>): void;
822 /**
823 * Allows to pass the compile summary from AOT compilation to the JIT compiler,
824 * so that it can use the code generated by AOT.
825 */
826 loadAotSummaries(summaries: () => any[]): void;
827 /**
828 * Gets the component factory for the given component.
829 * This assumes that the component has been compiled before calling this call using
830 * `compileModuleAndAllComponents*`.
831 */
832 getComponentFactory<T>(component: Type<T>): ComponentFactory<T>;
833 /**
834 * Returns the component type that is stored in the given error.
835 * This can be used for errors created by compileModule...
836 */
837 getComponentFromError(error: Error): Type<any> | null;
838}
839
840/**
841 * A factory for creating a Compiler
842 *
843 * @publicApi
844 */
845export declare abstract class ɵTestingCompilerFactory {
846 abstract createTestingCompiler(options?: CompilerOptions[]): ɵTestingCompiler;
847}
848
849export { }
850
\No newline at end of file