@angular/core 14.1.3 → 14.2.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/esm2020/src/application_ref.mjs +26 -21
  2. package/esm2020/src/core_private_export.mjs +3 -3
  3. package/esm2020/src/core_render3_private_export.mjs +4 -4
  4. package/esm2020/src/di/interface/defs.mjs +4 -1
  5. package/esm2020/src/render3/component_ref.mjs +4 -31
  6. package/esm2020/src/render3/definition.mjs +5 -1
  7. package/esm2020/src/render3/index.mjs +4 -4
  8. package/esm2020/src/render3/instructions/change_detection.mjs +3 -19
  9. package/esm2020/src/render3/instructions/shared.mjs +1 -43
  10. package/esm2020/src/render3/interfaces/view.mjs +1 -1
  11. package/esm2020/src/render3/jit/module.mjs +2 -6
  12. package/esm2020/src/render3/util/change_detection_utils.mjs +7 -3
  13. package/esm2020/src/render3/util/misc_utils.mjs +1 -7
  14. package/esm2020/src/version.mjs +1 -1
  15. package/esm2020/testing/src/logger.mjs +3 -3
  16. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  17. package/esm2020/testing/src/resolvers.mjs +1 -1
  18. package/esm2020/testing/src/test_bed.mjs +442 -15
  19. package/esm2020/testing/src/test_bed_common.mjs +1 -1
  20. package/esm2020/testing/src/test_bed_compiler.mjs +823 -0
  21. package/esm2020/testing/src/test_hooks.mjs +5 -5
  22. package/esm2020/testing/src/testing.mjs +1 -1
  23. package/fesm2015/core.mjs +38 -116
  24. package/fesm2015/core.mjs.map +1 -1
  25. package/fesm2015/testing.mjs +114 -202
  26. package/fesm2015/testing.mjs.map +1 -1
  27. package/fesm2020/core.mjs +38 -116
  28. package/fesm2020/core.mjs.map +1 -1
  29. package/fesm2020/testing.mjs +114 -203
  30. package/fesm2020/testing.mjs.map +1 -1
  31. package/index.d.ts +13 -100
  32. package/package.json +1 -1
  33. package/testing/index.d.ts +18 -94
  34. package/esm2020/src/render3/interfaces/player.mjs +0 -9
  35. package/esm2020/testing/src/r3_test_bed.mjs +0 -433
  36. package/esm2020/testing/src/r3_test_bed_compiler.mjs +0 -823
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @license Angular v14.1.3
2
+ * @license Angular v14.2.0-rc.0
3
3
  * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import { getDebugNode as getDebugNode$1, RendererFactory2 as RendererFactory2$1, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef as resolveForwardRef$1, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID as LOCALE_ID$1, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, NgZone, Compiler, COMPILER_OPTIONS, ɵNgModuleFactory, ModuleWithComponentFactories, InjectionToken as InjectionToken$1, Injector as Injector$1, InjectFlags as InjectFlags$1, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode as ɵsetUnknownElementStrictMode$1, ɵsetUnknownPropertyStrictMode as ɵsetUnknownPropertyStrictMode$1, ɵgetUnknownElementStrictMode as ɵgetUnknownElementStrictMode$1, ɵgetUnknownPropertyStrictMode as ɵgetUnknownPropertyStrictMode$1, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
7
+ import { getDebugNode as getDebugNode$1, RendererFactory2 as RendererFactory2$1, InjectionToken as InjectionToken$1, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef as resolveForwardRef$1, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID as LOCALE_ID$1, ɵDEFAULT_LOCALE_ID, ɵsetLocaleId, ɵRender3ComponentFactory, ɵcompileComponent, ɵNG_DIR_DEF, ɵcompileDirective, ɵNG_PIPE_DEF, ɵcompilePipe, ɵNG_MOD_DEF, ɵtransitiveScopesFor, ɵpatchComponentDefWithScope, ɵNG_INJ_DEF, ɵcompileNgModuleDefs, NgZone, Compiler, COMPILER_OPTIONS, ɵNgModuleFactory, ModuleWithComponentFactories, Injector as Injector$1, InjectFlags as InjectFlags$1, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode as ɵsetUnknownElementStrictMode$1, ɵsetUnknownPropertyStrictMode as ɵsetUnknownPropertyStrictMode$1, ɵgetUnknownElementStrictMode as ɵgetUnknownElementStrictMode$1, ɵgetUnknownPropertyStrictMode as ɵgetUnknownPropertyStrictMode$1, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
8
8
  import { __awaiter } from 'tslib';
9
9
  import { ResourceLoader } from '@angular/compiler';
10
10
  import { Subject, Subscription } from 'rxjs';
@@ -414,6 +414,37 @@ function flushMicrotasks() {
414
414
  throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
415
415
  }
416
416
 
417
+ /**
418
+ * @license
419
+ * Copyright Google LLC All Rights Reserved.
420
+ *
421
+ * Use of this source code is governed by an MIT-style license that can be
422
+ * found in the LICENSE file at https://angular.io/license
423
+ */
424
+ /** Whether test modules should be torn down by default. */
425
+ const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
426
+ /** Whether unknown elements in templates should throw by default. */
427
+ const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
428
+ /** Whether unknown properties in templates should throw by default. */
429
+ const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
430
+ /**
431
+ * An abstract class for inserting the root test component element in a platform independent way.
432
+ *
433
+ * @publicApi
434
+ */
435
+ class TestComponentRenderer {
436
+ insertRootElement(rootElementId) { }
437
+ removeAllRootElements() { }
438
+ }
439
+ /**
440
+ * @publicApi
441
+ */
442
+ const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
443
+ /**
444
+ * @publicApi
445
+ */
446
+ const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
447
+
417
448
  /**
418
449
  * @license
419
450
  * Copyright Google LLC All Rights Reserved.
@@ -804,6 +835,9 @@ function ɵɵdefineInjector(options) {
804
835
  function getInjectableDef(type) {
805
836
  return getOwnDefinition(type, NG_PROV_DEF) || getOwnDefinition(type, NG_INJECTABLE_DEF);
806
837
  }
838
+ function isInjectable(type) {
839
+ return getInjectableDef(type) !== null;
840
+ }
807
841
  /**
808
842
  * Return definition only if it is defined directly on `type` and is not inherited from a base
809
843
  * class of `type`.
@@ -2742,6 +2776,10 @@ function getDirectiveDef(type) {
2742
2776
  function getPipeDef$1(type) {
2743
2777
  return type[NG_PIPE_DEF] || null;
2744
2778
  }
2779
+ function isStandalone(type) {
2780
+ const def = getComponentDef$1(type) || getDirectiveDef(type) || getPipeDef$1(type);
2781
+ return def !== null ? def.standalone : false;
2782
+ }
2745
2783
  function getNgModuleDef(type, throwNotFound) {
2746
2784
  const ngModuleDef = type[NG_MOD_DEF] || null;
2747
2785
  if (!ngModuleDef && throwNotFound === true) {
@@ -5467,11 +5505,6 @@ function setAllowDuplicateNgModuleIdsForTest(allowDuplicates) {
5467
5505
  * Use of this source code is governed by an MIT-style license that can be
5468
5506
  * found in the LICENSE file at https://angular.io/license
5469
5507
  */
5470
- const defaultScheduler = (() => (typeof requestAnimationFrame !== 'undefined' &&
5471
- requestAnimationFrame || // browser only
5472
- setTimeout // everything else
5473
- )
5474
- .bind(_global$1))();
5475
5508
  /**
5476
5509
  *
5477
5510
  * @codeGenApi
@@ -7614,7 +7647,7 @@ class Version {
7614
7647
  /**
7615
7648
  * @publicApi
7616
7649
  */
7617
- const VERSION = new Version('14.1.3');
7650
+ const VERSION = new Version('14.2.0-rc.0');
7618
7651
 
7619
7652
  /**
7620
7653
  * @license
@@ -12012,11 +12045,6 @@ class LContainerDebug {
12012
12045
  * Use of this source code is governed by an MIT-style license that can be
12013
12046
  * found in the LICENSE file at https://angular.io/license
12014
12047
  */
12015
- /**
12016
- * A permanent marker promise which signifies that the current CD tree is
12017
- * clean.
12018
- */
12019
- const _CLEAN_PROMISE = (() => Promise.resolve(null))();
12020
12048
  /**
12021
12049
  * Invoke `HostBindingsFunction`s for view.
12022
12050
  *
@@ -13514,42 +13542,6 @@ function markViewDirty(lView) {
13514
13542
  }
13515
13543
  return null;
13516
13544
  }
13517
- /**
13518
- * Used to schedule change detection on the whole application.
13519
- *
13520
- * Unlike `tick`, `scheduleTick` coalesces multiple calls into one change detection run.
13521
- * It is usually called indirectly by calling `markDirty` when the view needs to be
13522
- * re-rendered.
13523
- *
13524
- * Typically `scheduleTick` uses `requestAnimationFrame` to coalesce multiple
13525
- * `scheduleTick` requests. The scheduling function can be overridden in
13526
- * `renderComponent`'s `scheduler` option.
13527
- */
13528
- function scheduleTick(rootContext, flags) {
13529
- const nothingScheduled = rootContext.flags === 0 /* RootContextFlags.Empty */;
13530
- if (nothingScheduled && rootContext.clean == _CLEAN_PROMISE) {
13531
- // https://github.com/angular/angular/issues/39296
13532
- // should only attach the flags when really scheduling a tick
13533
- rootContext.flags |= flags;
13534
- let res;
13535
- rootContext.clean = new Promise((r) => res = r);
13536
- rootContext.scheduler(() => {
13537
- if (rootContext.flags & 1 /* RootContextFlags.DetectChanges */) {
13538
- rootContext.flags &= ~1 /* RootContextFlags.DetectChanges */;
13539
- tickRootContext(rootContext);
13540
- }
13541
- if (rootContext.flags & 2 /* RootContextFlags.FlushPlayers */) {
13542
- rootContext.flags &= ~2 /* RootContextFlags.FlushPlayers */;
13543
- const playerHandler = rootContext.playerHandler;
13544
- if (playerHandler) {
13545
- playerHandler.flushPlayers();
13546
- }
13547
- }
13548
- rootContext.clean = _CLEAN_PROMISE;
13549
- res(null);
13550
- });
13551
- }
13552
- }
13553
13545
  function tickRootContext(rootContext) {
13554
13546
  for (let i = 0; i < rootContext.components.length; i++) {
13555
13547
  const rootComponent = rootContext.components[i];
@@ -13658,7 +13650,6 @@ function storePropertyBindingMetadata(tData, tNode, propertyName, bindingIndex,
13658
13650
  }
13659
13651
  }
13660
13652
  }
13661
- const CLEAN_PROMISE = _CLEAN_PROMISE;
13662
13653
  function getOrCreateLViewCleanup(view) {
13663
13654
  // top level variables should not be exported for performance reasons (PERF_NOTES.md)
13664
13655
  return view[CLEANUP] || (view[CLEANUP] = ngDevMode ? new LCleanup() : []);
@@ -14417,14 +14408,8 @@ function createRootComponent(componentView, componentDef, rootLView, rootContext
14417
14408
  }
14418
14409
  return component;
14419
14410
  }
14420
- function createRootContext(scheduler, playerHandler) {
14421
- return {
14422
- components: [],
14423
- scheduler: scheduler || defaultScheduler,
14424
- clean: CLEAN_PROMISE,
14425
- playerHandler: playerHandler || null,
14426
- flags: 0 /* RootContextFlags.Empty */
14427
- };
14411
+ function createRootContext() {
14412
+ return { components: [] };
14428
14413
  }
14429
14414
  /**
14430
14415
  * Used to enable lifecycle hooks on the root component.
@@ -14444,25 +14429,6 @@ function LifecycleHooksFeature() {
14444
14429
  ngDevMode && assertDefined(tNode, 'TNode is required');
14445
14430
  registerPostOrderHooks(getLView()[TVIEW], tNode);
14446
14431
  }
14447
- /**
14448
- * Wait on component until it is rendered.
14449
- *
14450
- * This function returns a `Promise` which is resolved when the component's
14451
- * change detection is executed. This is determined by finding the scheduler
14452
- * associated with the `component`'s render tree and waiting until the scheduler
14453
- * flushes. If nothing is scheduled, the function returns a resolved promise.
14454
- *
14455
- * Example:
14456
- * ```
14457
- * await whenRendered(myComponent);
14458
- * ```
14459
- *
14460
- * @param component Component to wait upon
14461
- * @returns Promise which resolves when the component is rendered.
14462
- */
14463
- function whenRendered(component) {
14464
- return getRootContext(component).clean;
14465
- }
14466
14432
 
14467
14433
  /**
14468
14434
  * @license
@@ -15447,21 +15413,6 @@ function detectChanges(component) {
15447
15413
  const view = getComponentViewByInstance(component);
15448
15414
  detectChangesInternal(view[TVIEW], view, component);
15449
15415
  }
15450
- /**
15451
- * Marks the component as dirty (needing change detection). Marking a component dirty will
15452
- * schedule a change detection on it at some point in the future.
15453
- *
15454
- * Marking an already dirty component as dirty won't do anything. Only one outstanding change
15455
- * detection can be scheduled per component tree.
15456
- *
15457
- * @param component Component to mark as dirty.
15458
- */
15459
- function markDirty(component) {
15460
- ngDevMode && assertDefined(component, 'component');
15461
- const rootView = markViewDirty(getComponentViewByInstance(component));
15462
- ngDevMode && assertDefined(rootView[CONTEXT], 'rootContext should be defined');
15463
- scheduleTick(rootView[CONTEXT], 1 /* RootContextFlags.DetectChanges */);
15464
- }
15465
15416
 
15466
15417
  /**
15467
15418
  * @license
@@ -24624,10 +24575,6 @@ function compileNgModuleDefs(moduleType, ngModule, allowDuplicateDeclarationsInR
24624
24575
  configurable: !!ngDevMode,
24625
24576
  });
24626
24577
  }
24627
- function isStandalone(type) {
24628
- const def = getComponentDef$1(type) || getDirectiveDef(type) || getPipeDef$1(type);
24629
- return def !== null ? def.standalone : false;
24630
- }
24631
24578
  function generateStandaloneInDeclarationsError(type, location) {
24632
24579
  const prefix = `Unexpected "${stringifyForError(type)}" found in the "declarations" array of the`;
24633
24580
  const suffix = `"${stringifyForError(type)}" is marked as standalone and can't be declared ` +
@@ -25231,7 +25178,7 @@ function assertNoStandaloneComponents(types, resolver, location) {
25231
25178
  }
25232
25179
  });
25233
25180
  }
25234
- class R3TestBedCompiler {
25181
+ class TestBedCompiler {
25235
25182
  constructor(platform, additionalModuleTypes) {
25236
25183
  this.platform = platform;
25237
25184
  this.additionalModuleTypes = additionalModuleTypes;
@@ -26044,49 +25991,23 @@ class R3TestCompiler {
26044
25991
  * Use of this source code is governed by an MIT-style license that can be
26045
25992
  * found in the LICENSE file at https://angular.io/license
26046
25993
  */
26047
- /** Whether test modules should be torn down by default. */
26048
- const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
26049
- /** Whether unknown elements in templates should throw by default. */
26050
- const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
26051
- /** Whether unknown properties in templates should throw by default. */
26052
- const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
25994
+ let _nextRootElementId = 0;
26053
25995
  /**
26054
- * An abstract class for inserting the root test component element in a platform independent way.
25996
+ * Returns a singleton of the `TestBed` class.
26055
25997
  *
26056
25998
  * @publicApi
26057
25999
  */
26058
- class TestComponentRenderer {
26059
- insertRootElement(rootElementId) { }
26060
- removeAllRootElements() { }
26000
+ function getTestBed() {
26001
+ return TestBedImpl.INSTANCE;
26061
26002
  }
26062
- /**
26063
- * @publicApi
26064
- */
26065
- const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
26066
- /**
26067
- * @publicApi
26068
- */
26069
- const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
26070
-
26071
- /**
26072
- * @license
26073
- * Copyright Google LLC All Rights Reserved.
26074
- *
26075
- * Use of this source code is governed by an MIT-style license that can be
26076
- * found in the LICENSE file at https://angular.io/license
26077
- */
26078
- let _nextRootElementId = 0;
26079
26003
  /**
26080
26004
  * @description
26081
26005
  * Configures and initializes environment for unit testing and provides methods for
26082
26006
  * creating components and services in unit tests.
26083
26007
  *
26084
26008
  * TestBed is the primary api for writing unit tests for Angular applications and libraries.
26085
- *
26086
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
26087
- * according to the compiler used.
26088
26009
  */
26089
- class TestBedRender3 {
26010
+ class TestBedImpl {
26090
26011
  constructor() {
26091
26012
  // Properties
26092
26013
  this.platform = null;
@@ -26094,7 +26015,15 @@ class TestBedRender3 {
26094
26015
  this._compiler = null;
26095
26016
  this._testModuleRef = null;
26096
26017
  this._activeFixtures = [];
26097
- this._globalCompilationChecked = false;
26018
+ /**
26019
+ * Internal-only flag to indicate whether a module
26020
+ * scoping queue has been checked and flushed already.
26021
+ * @nodoc
26022
+ */
26023
+ this.globalCompilationChecked = false;
26024
+ }
26025
+ static get INSTANCE() {
26026
+ return TestBedImpl._INSTANCE = TestBedImpl._INSTANCE || new TestBedImpl();
26098
26027
  }
26099
26028
  /**
26100
26029
  * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
@@ -26110,7 +26039,7 @@ class TestBedRender3 {
26110
26039
  * @publicApi
26111
26040
  */
26112
26041
  static initTestEnvironment(ngModule, platform, options) {
26113
- const testBed = _getTestBedRender3();
26042
+ const testBed = TestBedImpl.INSTANCE;
26114
26043
  testBed.initTestEnvironment(ngModule, platform, options);
26115
26044
  return testBed;
26116
26045
  }
@@ -26120,19 +26049,17 @@ class TestBedRender3 {
26120
26049
  * @publicApi
26121
26050
  */
26122
26051
  static resetTestEnvironment() {
26123
- _getTestBedRender3().resetTestEnvironment();
26052
+ TestBedImpl.INSTANCE.resetTestEnvironment();
26124
26053
  }
26125
26054
  static configureCompiler(config) {
26126
- _getTestBedRender3().configureCompiler(config);
26127
- return TestBedRender3;
26055
+ return TestBedImpl.INSTANCE.configureCompiler(config);
26128
26056
  }
26129
26057
  /**
26130
26058
  * Allows overriding default providers, directives, pipes, modules of the test injector,
26131
26059
  * which are defined in test_injector.js
26132
26060
  */
26133
26061
  static configureTestingModule(moduleDef) {
26134
- _getTestBedRender3().configureTestingModule(moduleDef);
26135
- return TestBedRender3;
26062
+ return TestBedImpl.INSTANCE.configureTestingModule(moduleDef);
26136
26063
  }
26137
26064
  /**
26138
26065
  * Compile components with a `templateUrl` for the test's NgModule.
@@ -26140,27 +26067,22 @@ class TestBedRender3 {
26140
26067
  * as fetching urls is asynchronous.
26141
26068
  */
26142
26069
  static compileComponents() {
26143
- return _getTestBedRender3().compileComponents();
26070
+ return TestBedImpl.INSTANCE.compileComponents();
26144
26071
  }
26145
26072
  static overrideModule(ngModule, override) {
26146
- _getTestBedRender3().overrideModule(ngModule, override);
26147
- return TestBedRender3;
26073
+ return TestBedImpl.INSTANCE.overrideModule(ngModule, override);
26148
26074
  }
26149
26075
  static overrideComponent(component, override) {
26150
- _getTestBedRender3().overrideComponent(component, override);
26151
- return TestBedRender3;
26076
+ return TestBedImpl.INSTANCE.overrideComponent(component, override);
26152
26077
  }
26153
26078
  static overrideDirective(directive, override) {
26154
- _getTestBedRender3().overrideDirective(directive, override);
26155
- return TestBedRender3;
26079
+ return TestBedImpl.INSTANCE.overrideDirective(directive, override);
26156
26080
  }
26157
26081
  static overridePipe(pipe, override) {
26158
- _getTestBedRender3().overridePipe(pipe, override);
26159
- return TestBedRender3;
26082
+ return TestBedImpl.INSTANCE.overridePipe(pipe, override);
26160
26083
  }
26161
26084
  static overrideTemplate(component, template) {
26162
- _getTestBedRender3().overrideComponent(component, { set: { template, templateUrl: null } });
26163
- return TestBedRender3;
26085
+ return TestBedImpl.INSTANCE.overrideTemplate(component, template);
26164
26086
  }
26165
26087
  /**
26166
26088
  * Overrides the template of the given component, compiling the template
@@ -26169,32 +26091,32 @@ class TestBedRender3 {
26169
26091
  * Note: This works for JIT and AOTed components as well.
26170
26092
  */
26171
26093
  static overrideTemplateUsingTestingModule(component, template) {
26172
- _getTestBedRender3().overrideTemplateUsingTestingModule(component, template);
26173
- return TestBedRender3;
26094
+ return TestBedImpl.INSTANCE.overrideTemplateUsingTestingModule(component, template);
26174
26095
  }
26175
26096
  static overrideProvider(token, provider) {
26176
- _getTestBedRender3().overrideProvider(token, provider);
26177
- return TestBedRender3;
26097
+ return TestBedImpl.INSTANCE.overrideProvider(token, provider);
26178
26098
  }
26179
26099
  static inject(token, notFoundValue, flags) {
26180
- return _getTestBedRender3().inject(token, notFoundValue, flags);
26100
+ return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
26181
26101
  }
26182
26102
  /** @deprecated from v9.0.0 use TestBed.inject */
26183
26103
  static get(token, notFoundValue = Injector$1.THROW_IF_NOT_FOUND, flags = InjectFlags$1.Default) {
26184
- return _getTestBedRender3().inject(token, notFoundValue, flags);
26104
+ return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
26185
26105
  }
26186
26106
  static createComponent(component) {
26187
- return _getTestBedRender3().createComponent(component);
26107
+ return TestBedImpl.INSTANCE.createComponent(component);
26188
26108
  }
26189
26109
  static resetTestingModule() {
26190
- _getTestBedRender3().resetTestingModule();
26191
- return TestBedRender3;
26110
+ return TestBedImpl.INSTANCE.resetTestingModule();
26192
26111
  }
26193
- static shouldTearDownTestingModule() {
26194
- return _getTestBedRender3().shouldTearDownTestingModule();
26112
+ static execute(tokens, fn, context) {
26113
+ return TestBedImpl.INSTANCE.execute(tokens, fn, context);
26195
26114
  }
26196
- static tearDownTestingModule() {
26197
- _getTestBedRender3().tearDownTestingModule();
26115
+ static get platform() {
26116
+ return TestBedImpl.INSTANCE.platform;
26117
+ }
26118
+ static get ngModule() {
26119
+ return TestBedImpl.INSTANCE.ngModule;
26198
26120
  }
26199
26121
  /**
26200
26122
  * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
@@ -26213,12 +26135,12 @@ class TestBedRender3 {
26213
26135
  if (this.platform || this.ngModule) {
26214
26136
  throw new Error('Cannot set base providers because it has already been called');
26215
26137
  }
26216
- TestBedRender3._environmentTeardownOptions = options === null || options === void 0 ? void 0 : options.teardown;
26217
- TestBedRender3._environmentErrorOnUnknownElementsOption = options === null || options === void 0 ? void 0 : options.errorOnUnknownElements;
26218
- TestBedRender3._environmentErrorOnUnknownPropertiesOption = options === null || options === void 0 ? void 0 : options.errorOnUnknownProperties;
26138
+ TestBedImpl._environmentTeardownOptions = options === null || options === void 0 ? void 0 : options.teardown;
26139
+ TestBedImpl._environmentErrorOnUnknownElementsOption = options === null || options === void 0 ? void 0 : options.errorOnUnknownElements;
26140
+ TestBedImpl._environmentErrorOnUnknownPropertiesOption = options === null || options === void 0 ? void 0 : options.errorOnUnknownProperties;
26219
26141
  this.platform = platform;
26220
26142
  this.ngModule = ngModule;
26221
- this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
26143
+ this._compiler = new TestBedCompiler(this.platform, this.ngModule);
26222
26144
  // TestBed does not have an API which can reliably detect the start of a test, and thus could be
26223
26145
  // used to track the state of the NgModule registry and reset it correctly. Instead, when we
26224
26146
  // know we're in a testing scenario, we disable the check for duplicate NgModule registration
@@ -26235,7 +26157,7 @@ class TestBedRender3 {
26235
26157
  this._compiler = null;
26236
26158
  this.platform = null;
26237
26159
  this.ngModule = null;
26238
- TestBedRender3._environmentTeardownOptions = undefined;
26160
+ TestBedImpl._environmentTeardownOptions = undefined;
26239
26161
  ɵsetAllowDuplicateNgModuleIdsForTest(false);
26240
26162
  }
26241
26163
  resetTestingModule() {
@@ -26245,7 +26167,7 @@ class TestBedRender3 {
26245
26167
  if (this._compiler !== null) {
26246
26168
  this.compiler.restoreOriginalState();
26247
26169
  }
26248
- this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
26170
+ this._compiler = new TestBedCompiler(this.platform, this.ngModule);
26249
26171
  // Restore the previous value of the "error on unknown elements" option
26250
26172
  ɵsetUnknownElementStrictMode$1((_a = this._previousErrorOnUnknownElementsOption) !== null && _a !== void 0 ? _a : THROW_ON_UNKNOWN_ELEMENTS_DEFAULT);
26251
26173
  // Restore the previous value of the "error on unknown properties" option
@@ -26269,6 +26191,7 @@ class TestBedRender3 {
26269
26191
  this._instanceErrorOnUnknownPropertiesOption = undefined;
26270
26192
  }
26271
26193
  }
26194
+ return this;
26272
26195
  }
26273
26196
  configureCompiler(config) {
26274
26197
  if (config.useJit != null) {
@@ -26277,6 +26200,7 @@ class TestBedRender3 {
26277
26200
  if (config.providers !== undefined) {
26278
26201
  this.compiler.setCompilerProviders(config.providers);
26279
26202
  }
26203
+ return this;
26280
26204
  }
26281
26205
  configureTestingModule(moduleDef) {
26282
26206
  this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
@@ -26297,12 +26221,13 @@ class TestBedRender3 {
26297
26221
  this._previousErrorOnUnknownPropertiesOption = ɵgetUnknownPropertyStrictMode$1();
26298
26222
  ɵsetUnknownPropertyStrictMode$1(this.shouldThrowErrorOnUnknownProperties());
26299
26223
  this.compiler.configureTestingModule(moduleDef);
26224
+ return this;
26300
26225
  }
26301
26226
  compileComponents() {
26302
26227
  return this.compiler.compileComponents();
26303
26228
  }
26304
26229
  inject(token, notFoundValue, flags) {
26305
- if (token === TestBedRender3) {
26230
+ if (token === TestBed) {
26306
26231
  return this;
26307
26232
  }
26308
26233
  const UNDEFINED = {};
@@ -26321,22 +26246,27 @@ class TestBedRender3 {
26321
26246
  overrideModule(ngModule, override) {
26322
26247
  this.assertNotInstantiated('overrideModule', 'override module metadata');
26323
26248
  this.compiler.overrideModule(ngModule, override);
26249
+ return this;
26324
26250
  }
26325
26251
  overrideComponent(component, override) {
26326
26252
  this.assertNotInstantiated('overrideComponent', 'override component metadata');
26327
26253
  this.compiler.overrideComponent(component, override);
26254
+ return this;
26328
26255
  }
26329
26256
  overrideTemplateUsingTestingModule(component, template) {
26330
26257
  this.assertNotInstantiated('R3TestBed.overrideTemplateUsingTestingModule', 'Cannot override template when the test module has already been instantiated');
26331
26258
  this.compiler.overrideTemplateUsingTestingModule(component, template);
26259
+ return this;
26332
26260
  }
26333
26261
  overrideDirective(directive, override) {
26334
26262
  this.assertNotInstantiated('overrideDirective', 'override directive metadata');
26335
26263
  this.compiler.overrideDirective(directive, override);
26264
+ return this;
26336
26265
  }
26337
26266
  overridePipe(pipe, override) {
26338
26267
  this.assertNotInstantiated('overridePipe', 'override pipe metadata');
26339
26268
  this.compiler.overridePipe(pipe, override);
26269
+ return this;
26340
26270
  }
26341
26271
  /**
26342
26272
  * Overwrites all providers for the given token with the given provider definition.
@@ -26344,6 +26274,10 @@ class TestBedRender3 {
26344
26274
  overrideProvider(token, provider) {
26345
26275
  this.assertNotInstantiated('overrideProvider', 'override provider');
26346
26276
  this.compiler.overrideProvider(token, provider);
26277
+ return this;
26278
+ }
26279
+ overrideTemplate(component, template) {
26280
+ return this.overrideComponent(component, { set: { template, templateUrl: null } });
26347
26281
  }
26348
26282
  createComponent(type) {
26349
26283
  const testComponentRenderer = this.inject(TestComponentRenderer);
@@ -26408,10 +26342,10 @@ class TestBedRender3 {
26408
26342
  checkGlobalCompilationFinished() {
26409
26343
  // Checking _testNgModuleRef is null should not be necessary, but is left in as an additional
26410
26344
  // guard that compilations queued in tests (after instantiation) are never flushed accidentally.
26411
- if (!this._globalCompilationChecked && this._testModuleRef === null) {
26345
+ if (!this.globalCompilationChecked && this._testModuleRef === null) {
26412
26346
  ɵflushModuleScopingQueueAsMuchAsPossible();
26413
26347
  }
26414
- this._globalCompilationChecked = true;
26348
+ this.globalCompilationChecked = true;
26415
26349
  }
26416
26350
  destroyActiveFixtures() {
26417
26351
  let errorCount = 0;
@@ -26436,7 +26370,7 @@ class TestBedRender3 {
26436
26370
  shouldRethrowTeardownErrors() {
26437
26371
  var _a, _b;
26438
26372
  const instanceOptions = this._instanceTeardownOptions;
26439
- const environmentOptions = TestBedRender3._environmentTeardownOptions;
26373
+ const environmentOptions = TestBedImpl._environmentTeardownOptions;
26440
26374
  // If the new teardown behavior hasn't been configured, preserve the old behavior.
26441
26375
  if (!instanceOptions && !environmentOptions) {
26442
26376
  return TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
@@ -26447,16 +26381,16 @@ class TestBedRender3 {
26447
26381
  shouldThrowErrorOnUnknownElements() {
26448
26382
  var _a, _b;
26449
26383
  // Check if a configuration has been provided to throw when an unknown element is found
26450
- return (_b = (_a = this._instanceErrorOnUnknownElementsOption) !== null && _a !== void 0 ? _a : TestBedRender3._environmentErrorOnUnknownElementsOption) !== null && _b !== void 0 ? _b : THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
26384
+ return (_b = (_a = this._instanceErrorOnUnknownElementsOption) !== null && _a !== void 0 ? _a : TestBedImpl._environmentErrorOnUnknownElementsOption) !== null && _b !== void 0 ? _b : THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
26451
26385
  }
26452
26386
  shouldThrowErrorOnUnknownProperties() {
26453
26387
  var _a, _b;
26454
26388
  // Check if a configuration has been provided to throw when an unknown property is found
26455
- return (_b = (_a = this._instanceErrorOnUnknownPropertiesOption) !== null && _a !== void 0 ? _a : TestBedRender3._environmentErrorOnUnknownPropertiesOption) !== null && _b !== void 0 ? _b : THROW_ON_UNKNOWN_PROPERTIES_DEFAULT;
26389
+ return (_b = (_a = this._instanceErrorOnUnknownPropertiesOption) !== null && _a !== void 0 ? _a : TestBedImpl._environmentErrorOnUnknownPropertiesOption) !== null && _b !== void 0 ? _b : THROW_ON_UNKNOWN_PROPERTIES_DEFAULT;
26456
26390
  }
26457
26391
  shouldTearDownTestingModule() {
26458
26392
  var _a, _b, _c, _d;
26459
- return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedRender3._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
26393
+ return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedImpl._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
26460
26394
  }
26461
26395
  tearDownTestingModule() {
26462
26396
  var _a;
@@ -26486,18 +26420,7 @@ class TestBedRender3 {
26486
26420
  }
26487
26421
  }
26488
26422
  }
26489
- let testBed;
26490
- function _getTestBedRender3() {
26491
- return testBed = testBed || new TestBedRender3();
26492
- }
26493
-
26494
- /**
26495
- * @license
26496
- * Copyright Google LLC All Rights Reserved.
26497
- *
26498
- * Use of this source code is governed by an MIT-style license that can be
26499
- * found in the LICENSE file at https://angular.io/license
26500
- */
26423
+ TestBedImpl._INSTANCE = null;
26501
26424
  /**
26502
26425
  * @description
26503
26426
  * Configures and initializes environment for unit testing and provides methods for
@@ -26505,20 +26428,9 @@ function _getTestBedRender3() {
26505
26428
  *
26506
26429
  * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
26507
26430
  *
26508
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
26509
- * according to the compiler used.
26510
- *
26511
- * @publicApi
26512
- */
26513
- const TestBed = TestBedRender3;
26514
- /**
26515
- * Returns a singleton of the applicable `TestBed`.
26516
- *
26517
- * It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
26518
- *
26519
26431
  * @publicApi
26520
26432
  */
26521
- const getTestBed = _getTestBedRender3;
26433
+ const TestBed = TestBedImpl;
26522
26434
  /**
26523
26435
  * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
26524
26436
  * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
@@ -26542,7 +26454,7 @@ const getTestBed = _getTestBedRender3;
26542
26454
  * @publicApi
26543
26455
  */
26544
26456
  function inject(tokens, fn) {
26545
- const testBed = getTestBed();
26457
+ const testBed = TestBedImpl.INSTANCE;
26546
26458
  // Not using an arrow function to preserve context passed from call site
26547
26459
  return function () {
26548
26460
  return testBed.execute(tokens, fn, this);
@@ -26558,7 +26470,7 @@ class InjectSetupWrapper {
26558
26470
  _addModule() {
26559
26471
  const moduleDef = this._moduleDef();
26560
26472
  if (moduleDef) {
26561
- getTestBed().configureTestingModule(moduleDef);
26473
+ TestBedImpl.configureTestingModule(moduleDef);
26562
26474
  }
26563
26475
  }
26564
26476
  inject(tokens, fn) {
@@ -26574,7 +26486,7 @@ function withModule(moduleDef, fn) {
26574
26486
  if (fn) {
26575
26487
  // Not using an arrow function to preserve context passed from call site
26576
26488
  return function () {
26577
- const testBed = getTestBed();
26489
+ const testBed = TestBedImpl.INSTANCE;
26578
26490
  if (moduleDef) {
26579
26491
  testBed.configureTestingModule(moduleDef);
26580
26492
  }
@@ -26604,9 +26516,9 @@ if (_global.afterEach) {
26604
26516
  }
26605
26517
  function getCleanupHook(expectedTeardownValue) {
26606
26518
  return () => {
26607
- // TODO(alxhub): find a better type here
26608
- if (TestBed.shouldTearDownTestingModule() === expectedTeardownValue) {
26609
- TestBed.resetTestingModule();
26519
+ const testBed = TestBedImpl.INSTANCE;
26520
+ if (testBed.shouldTearDownTestingModule() === expectedTeardownValue) {
26521
+ testBed.resetTestingModule();
26610
26522
  resetFakeAsyncZone();
26611
26523
  }
26612
26524
  };