@angular/core 14.1.1 → 14.2.0-next.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.
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @license Angular v14.1.1
2
+ * @license Angular v14.2.0-next.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 { ResourceLoader } from '@angular/compiler';
9
9
  import { Subject, Subscription } from 'rxjs';
10
10
 
@@ -413,6 +413,37 @@ function flushMicrotasks() {
413
413
  throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
414
414
  }
415
415
 
416
+ /**
417
+ * @license
418
+ * Copyright Google LLC All Rights Reserved.
419
+ *
420
+ * Use of this source code is governed by an MIT-style license that can be
421
+ * found in the LICENSE file at https://angular.io/license
422
+ */
423
+ /** Whether test modules should be torn down by default. */
424
+ const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
425
+ /** Whether unknown elements in templates should throw by default. */
426
+ const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
427
+ /** Whether unknown properties in templates should throw by default. */
428
+ const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
429
+ /**
430
+ * An abstract class for inserting the root test component element in a platform independent way.
431
+ *
432
+ * @publicApi
433
+ */
434
+ class TestComponentRenderer {
435
+ insertRootElement(rootElementId) { }
436
+ removeAllRootElements() { }
437
+ }
438
+ /**
439
+ * @publicApi
440
+ */
441
+ const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
442
+ /**
443
+ * @publicApi
444
+ */
445
+ const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
446
+
416
447
  /**
417
448
  * @license
418
449
  * Copyright Google LLC All Rights Reserved.
@@ -7618,7 +7649,7 @@ class Version {
7618
7649
  /**
7619
7650
  * @publicApi
7620
7651
  */
7621
- const VERSION = new Version('14.1.1');
7652
+ const VERSION = new Version('14.2.0-next.0');
7622
7653
 
7623
7654
  /**
7624
7655
  * @license
@@ -25237,7 +25268,7 @@ function assertNoStandaloneComponents(types, resolver, location) {
25237
25268
  }
25238
25269
  });
25239
25270
  }
25240
- class R3TestBedCompiler {
25271
+ class TestBedCompiler {
25241
25272
  constructor(platform, additionalModuleTypes) {
25242
25273
  this.platform = platform;
25243
25274
  this.additionalModuleTypes = additionalModuleTypes;
@@ -26038,49 +26069,23 @@ class R3TestCompiler {
26038
26069
  * Use of this source code is governed by an MIT-style license that can be
26039
26070
  * found in the LICENSE file at https://angular.io/license
26040
26071
  */
26041
- /** Whether test modules should be torn down by default. */
26042
- const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = true;
26043
- /** Whether unknown elements in templates should throw by default. */
26044
- const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
26045
- /** Whether unknown properties in templates should throw by default. */
26046
- const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
26072
+ let _nextRootElementId = 0;
26047
26073
  /**
26048
- * An abstract class for inserting the root test component element in a platform independent way.
26074
+ * Returns a singleton of the `TestBed` class.
26049
26075
  *
26050
26076
  * @publicApi
26051
26077
  */
26052
- class TestComponentRenderer {
26053
- insertRootElement(rootElementId) { }
26054
- removeAllRootElements() { }
26078
+ function getTestBed() {
26079
+ return TestBedImpl.INSTANCE;
26055
26080
  }
26056
- /**
26057
- * @publicApi
26058
- */
26059
- const ComponentFixtureAutoDetect = new InjectionToken$1('ComponentFixtureAutoDetect');
26060
- /**
26061
- * @publicApi
26062
- */
26063
- const ComponentFixtureNoNgZone = new InjectionToken$1('ComponentFixtureNoNgZone');
26064
-
26065
- /**
26066
- * @license
26067
- * Copyright Google LLC All Rights Reserved.
26068
- *
26069
- * Use of this source code is governed by an MIT-style license that can be
26070
- * found in the LICENSE file at https://angular.io/license
26071
- */
26072
- let _nextRootElementId = 0;
26073
26081
  /**
26074
26082
  * @description
26075
26083
  * Configures and initializes environment for unit testing and provides methods for
26076
26084
  * creating components and services in unit tests.
26077
26085
  *
26078
26086
  * TestBed is the primary api for writing unit tests for Angular applications and libraries.
26079
- *
26080
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
26081
- * according to the compiler used.
26082
26087
  */
26083
- class TestBedRender3 {
26088
+ class TestBedImpl {
26084
26089
  constructor() {
26085
26090
  // Properties
26086
26091
  this.platform = null;
@@ -26088,7 +26093,15 @@ class TestBedRender3 {
26088
26093
  this._compiler = null;
26089
26094
  this._testModuleRef = null;
26090
26095
  this._activeFixtures = [];
26091
- this._globalCompilationChecked = false;
26096
+ /**
26097
+ * Internal-only flag to indicate whether a module
26098
+ * scoping queue has been checked and flushed already.
26099
+ * @nodoc
26100
+ */
26101
+ this.globalCompilationChecked = false;
26102
+ }
26103
+ static get INSTANCE() {
26104
+ return TestBedImpl._INSTANCE = TestBedImpl._INSTANCE || new TestBedImpl();
26092
26105
  }
26093
26106
  /**
26094
26107
  * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
@@ -26104,7 +26117,7 @@ class TestBedRender3 {
26104
26117
  * @publicApi
26105
26118
  */
26106
26119
  static initTestEnvironment(ngModule, platform, options) {
26107
- const testBed = _getTestBedRender3();
26120
+ const testBed = TestBedImpl.INSTANCE;
26108
26121
  testBed.initTestEnvironment(ngModule, platform, options);
26109
26122
  return testBed;
26110
26123
  }
@@ -26114,19 +26127,17 @@ class TestBedRender3 {
26114
26127
  * @publicApi
26115
26128
  */
26116
26129
  static resetTestEnvironment() {
26117
- _getTestBedRender3().resetTestEnvironment();
26130
+ TestBedImpl.INSTANCE.resetTestEnvironment();
26118
26131
  }
26119
26132
  static configureCompiler(config) {
26120
- _getTestBedRender3().configureCompiler(config);
26121
- return TestBedRender3;
26133
+ return TestBedImpl.INSTANCE.configureCompiler(config);
26122
26134
  }
26123
26135
  /**
26124
26136
  * Allows overriding default providers, directives, pipes, modules of the test injector,
26125
26137
  * which are defined in test_injector.js
26126
26138
  */
26127
26139
  static configureTestingModule(moduleDef) {
26128
- _getTestBedRender3().configureTestingModule(moduleDef);
26129
- return TestBedRender3;
26140
+ return TestBedImpl.INSTANCE.configureTestingModule(moduleDef);
26130
26141
  }
26131
26142
  /**
26132
26143
  * Compile components with a `templateUrl` for the test's NgModule.
@@ -26134,27 +26145,22 @@ class TestBedRender3 {
26134
26145
  * as fetching urls is asynchronous.
26135
26146
  */
26136
26147
  static compileComponents() {
26137
- return _getTestBedRender3().compileComponents();
26148
+ return TestBedImpl.INSTANCE.compileComponents();
26138
26149
  }
26139
26150
  static overrideModule(ngModule, override) {
26140
- _getTestBedRender3().overrideModule(ngModule, override);
26141
- return TestBedRender3;
26151
+ return TestBedImpl.INSTANCE.overrideModule(ngModule, override);
26142
26152
  }
26143
26153
  static overrideComponent(component, override) {
26144
- _getTestBedRender3().overrideComponent(component, override);
26145
- return TestBedRender3;
26154
+ return TestBedImpl.INSTANCE.overrideComponent(component, override);
26146
26155
  }
26147
26156
  static overrideDirective(directive, override) {
26148
- _getTestBedRender3().overrideDirective(directive, override);
26149
- return TestBedRender3;
26157
+ return TestBedImpl.INSTANCE.overrideDirective(directive, override);
26150
26158
  }
26151
26159
  static overridePipe(pipe, override) {
26152
- _getTestBedRender3().overridePipe(pipe, override);
26153
- return TestBedRender3;
26160
+ return TestBedImpl.INSTANCE.overridePipe(pipe, override);
26154
26161
  }
26155
26162
  static overrideTemplate(component, template) {
26156
- _getTestBedRender3().overrideComponent(component, { set: { template, templateUrl: null } });
26157
- return TestBedRender3;
26163
+ return TestBedImpl.INSTANCE.overrideTemplate(component, template);
26158
26164
  }
26159
26165
  /**
26160
26166
  * Overrides the template of the given component, compiling the template
@@ -26163,32 +26169,32 @@ class TestBedRender3 {
26163
26169
  * Note: This works for JIT and AOTed components as well.
26164
26170
  */
26165
26171
  static overrideTemplateUsingTestingModule(component, template) {
26166
- _getTestBedRender3().overrideTemplateUsingTestingModule(component, template);
26167
- return TestBedRender3;
26172
+ return TestBedImpl.INSTANCE.overrideTemplateUsingTestingModule(component, template);
26168
26173
  }
26169
26174
  static overrideProvider(token, provider) {
26170
- _getTestBedRender3().overrideProvider(token, provider);
26171
- return TestBedRender3;
26175
+ return TestBedImpl.INSTANCE.overrideProvider(token, provider);
26172
26176
  }
26173
26177
  static inject(token, notFoundValue, flags) {
26174
- return _getTestBedRender3().inject(token, notFoundValue, flags);
26178
+ return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
26175
26179
  }
26176
26180
  /** @deprecated from v9.0.0 use TestBed.inject */
26177
26181
  static get(token, notFoundValue = Injector$1.THROW_IF_NOT_FOUND, flags = InjectFlags$1.Default) {
26178
- return _getTestBedRender3().inject(token, notFoundValue, flags);
26182
+ return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
26179
26183
  }
26180
26184
  static createComponent(component) {
26181
- return _getTestBedRender3().createComponent(component);
26185
+ return TestBedImpl.INSTANCE.createComponent(component);
26182
26186
  }
26183
26187
  static resetTestingModule() {
26184
- _getTestBedRender3().resetTestingModule();
26185
- return TestBedRender3;
26188
+ return TestBedImpl.INSTANCE.resetTestingModule();
26189
+ }
26190
+ static execute(tokens, fn, context) {
26191
+ return TestBedImpl.INSTANCE.execute(tokens, fn, context);
26186
26192
  }
26187
- static shouldTearDownTestingModule() {
26188
- return _getTestBedRender3().shouldTearDownTestingModule();
26193
+ static get platform() {
26194
+ return TestBedImpl.INSTANCE.platform;
26189
26195
  }
26190
- static tearDownTestingModule() {
26191
- _getTestBedRender3().tearDownTestingModule();
26196
+ static get ngModule() {
26197
+ return TestBedImpl.INSTANCE.ngModule;
26192
26198
  }
26193
26199
  /**
26194
26200
  * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
@@ -26207,12 +26213,12 @@ class TestBedRender3 {
26207
26213
  if (this.platform || this.ngModule) {
26208
26214
  throw new Error('Cannot set base providers because it has already been called');
26209
26215
  }
26210
- TestBedRender3._environmentTeardownOptions = options?.teardown;
26211
- TestBedRender3._environmentErrorOnUnknownElementsOption = options?.errorOnUnknownElements;
26212
- TestBedRender3._environmentErrorOnUnknownPropertiesOption = options?.errorOnUnknownProperties;
26216
+ TestBedImpl._environmentTeardownOptions = options?.teardown;
26217
+ TestBedImpl._environmentErrorOnUnknownElementsOption = options?.errorOnUnknownElements;
26218
+ TestBedImpl._environmentErrorOnUnknownPropertiesOption = options?.errorOnUnknownProperties;
26213
26219
  this.platform = platform;
26214
26220
  this.ngModule = ngModule;
26215
- this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
26221
+ this._compiler = new TestBedCompiler(this.platform, this.ngModule);
26216
26222
  // TestBed does not have an API which can reliably detect the start of a test, and thus could be
26217
26223
  // used to track the state of the NgModule registry and reset it correctly. Instead, when we
26218
26224
  // know we're in a testing scenario, we disable the check for duplicate NgModule registration
@@ -26229,7 +26235,7 @@ class TestBedRender3 {
26229
26235
  this._compiler = null;
26230
26236
  this.platform = null;
26231
26237
  this.ngModule = null;
26232
- TestBedRender3._environmentTeardownOptions = undefined;
26238
+ TestBedImpl._environmentTeardownOptions = undefined;
26233
26239
  ɵsetAllowDuplicateNgModuleIdsForTest(false);
26234
26240
  }
26235
26241
  resetTestingModule() {
@@ -26238,7 +26244,7 @@ class TestBedRender3 {
26238
26244
  if (this._compiler !== null) {
26239
26245
  this.compiler.restoreOriginalState();
26240
26246
  }
26241
- this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
26247
+ this._compiler = new TestBedCompiler(this.platform, this.ngModule);
26242
26248
  // Restore the previous value of the "error on unknown elements" option
26243
26249
  ɵsetUnknownElementStrictMode$1(this._previousErrorOnUnknownElementsOption ?? THROW_ON_UNKNOWN_ELEMENTS_DEFAULT);
26244
26250
  // Restore the previous value of the "error on unknown properties" option
@@ -26262,6 +26268,7 @@ class TestBedRender3 {
26262
26268
  this._instanceErrorOnUnknownPropertiesOption = undefined;
26263
26269
  }
26264
26270
  }
26271
+ return this;
26265
26272
  }
26266
26273
  configureCompiler(config) {
26267
26274
  if (config.useJit != null) {
@@ -26270,6 +26277,7 @@ class TestBedRender3 {
26270
26277
  if (config.providers !== undefined) {
26271
26278
  this.compiler.setCompilerProviders(config.providers);
26272
26279
  }
26280
+ return this;
26273
26281
  }
26274
26282
  configureTestingModule(moduleDef) {
26275
26283
  this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
@@ -26290,12 +26298,13 @@ class TestBedRender3 {
26290
26298
  this._previousErrorOnUnknownPropertiesOption = ɵgetUnknownPropertyStrictMode$1();
26291
26299
  ɵsetUnknownPropertyStrictMode$1(this.shouldThrowErrorOnUnknownProperties());
26292
26300
  this.compiler.configureTestingModule(moduleDef);
26301
+ return this;
26293
26302
  }
26294
26303
  compileComponents() {
26295
26304
  return this.compiler.compileComponents();
26296
26305
  }
26297
26306
  inject(token, notFoundValue, flags) {
26298
- if (token === TestBedRender3) {
26307
+ if (token === TestBed) {
26299
26308
  return this;
26300
26309
  }
26301
26310
  const UNDEFINED = {};
@@ -26314,22 +26323,27 @@ class TestBedRender3 {
26314
26323
  overrideModule(ngModule, override) {
26315
26324
  this.assertNotInstantiated('overrideModule', 'override module metadata');
26316
26325
  this.compiler.overrideModule(ngModule, override);
26326
+ return this;
26317
26327
  }
26318
26328
  overrideComponent(component, override) {
26319
26329
  this.assertNotInstantiated('overrideComponent', 'override component metadata');
26320
26330
  this.compiler.overrideComponent(component, override);
26331
+ return this;
26321
26332
  }
26322
26333
  overrideTemplateUsingTestingModule(component, template) {
26323
26334
  this.assertNotInstantiated('R3TestBed.overrideTemplateUsingTestingModule', 'Cannot override template when the test module has already been instantiated');
26324
26335
  this.compiler.overrideTemplateUsingTestingModule(component, template);
26336
+ return this;
26325
26337
  }
26326
26338
  overrideDirective(directive, override) {
26327
26339
  this.assertNotInstantiated('overrideDirective', 'override directive metadata');
26328
26340
  this.compiler.overrideDirective(directive, override);
26341
+ return this;
26329
26342
  }
26330
26343
  overridePipe(pipe, override) {
26331
26344
  this.assertNotInstantiated('overridePipe', 'override pipe metadata');
26332
26345
  this.compiler.overridePipe(pipe, override);
26346
+ return this;
26333
26347
  }
26334
26348
  /**
26335
26349
  * Overwrites all providers for the given token with the given provider definition.
@@ -26337,6 +26351,10 @@ class TestBedRender3 {
26337
26351
  overrideProvider(token, provider) {
26338
26352
  this.assertNotInstantiated('overrideProvider', 'override provider');
26339
26353
  this.compiler.overrideProvider(token, provider);
26354
+ return this;
26355
+ }
26356
+ overrideTemplate(component, template) {
26357
+ return this.overrideComponent(component, { set: { template, templateUrl: null } });
26340
26358
  }
26341
26359
  createComponent(type) {
26342
26360
  const testComponentRenderer = this.inject(TestComponentRenderer);
@@ -26401,10 +26419,10 @@ class TestBedRender3 {
26401
26419
  checkGlobalCompilationFinished() {
26402
26420
  // Checking _testNgModuleRef is null should not be necessary, but is left in as an additional
26403
26421
  // guard that compilations queued in tests (after instantiation) are never flushed accidentally.
26404
- if (!this._globalCompilationChecked && this._testModuleRef === null) {
26422
+ if (!this.globalCompilationChecked && this._testModuleRef === null) {
26405
26423
  ɵflushModuleScopingQueueAsMuchAsPossible();
26406
26424
  }
26407
- this._globalCompilationChecked = true;
26425
+ this.globalCompilationChecked = true;
26408
26426
  }
26409
26427
  destroyActiveFixtures() {
26410
26428
  let errorCount = 0;
@@ -26428,7 +26446,7 @@ class TestBedRender3 {
26428
26446
  }
26429
26447
  shouldRethrowTeardownErrors() {
26430
26448
  const instanceOptions = this._instanceTeardownOptions;
26431
- const environmentOptions = TestBedRender3._environmentTeardownOptions;
26449
+ const environmentOptions = TestBedImpl._environmentTeardownOptions;
26432
26450
  // If the new teardown behavior hasn't been configured, preserve the old behavior.
26433
26451
  if (!instanceOptions && !environmentOptions) {
26434
26452
  return TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
@@ -26440,18 +26458,17 @@ class TestBedRender3 {
26440
26458
  shouldThrowErrorOnUnknownElements() {
26441
26459
  // Check if a configuration has been provided to throw when an unknown element is found
26442
26460
  return this._instanceErrorOnUnknownElementsOption ??
26443
- TestBedRender3._environmentErrorOnUnknownElementsOption ??
26444
- THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
26461
+ TestBedImpl._environmentErrorOnUnknownElementsOption ?? THROW_ON_UNKNOWN_ELEMENTS_DEFAULT;
26445
26462
  }
26446
26463
  shouldThrowErrorOnUnknownProperties() {
26447
26464
  // Check if a configuration has been provided to throw when an unknown property is found
26448
26465
  return this._instanceErrorOnUnknownPropertiesOption ??
26449
- TestBedRender3._environmentErrorOnUnknownPropertiesOption ??
26466
+ TestBedImpl._environmentErrorOnUnknownPropertiesOption ??
26450
26467
  THROW_ON_UNKNOWN_PROPERTIES_DEFAULT;
26451
26468
  }
26452
26469
  shouldTearDownTestingModule() {
26453
26470
  return this._instanceTeardownOptions?.destroyAfterEach ??
26454
- TestBedRender3._environmentTeardownOptions?.destroyAfterEach ??
26471
+ TestBedImpl._environmentTeardownOptions?.destroyAfterEach ??
26455
26472
  TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
26456
26473
  }
26457
26474
  tearDownTestingModule() {
@@ -26481,18 +26498,7 @@ class TestBedRender3 {
26481
26498
  }
26482
26499
  }
26483
26500
  }
26484
- let testBed;
26485
- function _getTestBedRender3() {
26486
- return testBed = testBed || new TestBedRender3();
26487
- }
26488
-
26489
- /**
26490
- * @license
26491
- * Copyright Google LLC All Rights Reserved.
26492
- *
26493
- * Use of this source code is governed by an MIT-style license that can be
26494
- * found in the LICENSE file at https://angular.io/license
26495
- */
26501
+ TestBedImpl._INSTANCE = null;
26496
26502
  /**
26497
26503
  * @description
26498
26504
  * Configures and initializes environment for unit testing and provides methods for
@@ -26500,20 +26506,9 @@ function _getTestBedRender3() {
26500
26506
  *
26501
26507
  * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
26502
26508
  *
26503
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
26504
- * according to the compiler used.
26505
- *
26506
- * @publicApi
26507
- */
26508
- const TestBed = TestBedRender3;
26509
- /**
26510
- * Returns a singleton of the applicable `TestBed`.
26511
- *
26512
- * It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
26513
- *
26514
26509
  * @publicApi
26515
26510
  */
26516
- const getTestBed = _getTestBedRender3;
26511
+ const TestBed = TestBedImpl;
26517
26512
  /**
26518
26513
  * Allows injecting dependencies in `beforeEach()` and `it()`. Note: this function
26519
26514
  * (imported from the `@angular/core/testing` package) can **only** be used to inject dependencies
@@ -26537,7 +26532,7 @@ const getTestBed = _getTestBedRender3;
26537
26532
  * @publicApi
26538
26533
  */
26539
26534
  function inject(tokens, fn) {
26540
- const testBed = getTestBed();
26535
+ const testBed = TestBedImpl.INSTANCE;
26541
26536
  // Not using an arrow function to preserve context passed from call site
26542
26537
  return function () {
26543
26538
  return testBed.execute(tokens, fn, this);
@@ -26553,7 +26548,7 @@ class InjectSetupWrapper {
26553
26548
  _addModule() {
26554
26549
  const moduleDef = this._moduleDef();
26555
26550
  if (moduleDef) {
26556
- getTestBed().configureTestingModule(moduleDef);
26551
+ TestBedImpl.configureTestingModule(moduleDef);
26557
26552
  }
26558
26553
  }
26559
26554
  inject(tokens, fn) {
@@ -26569,7 +26564,7 @@ function withModule(moduleDef, fn) {
26569
26564
  if (fn) {
26570
26565
  // Not using an arrow function to preserve context passed from call site
26571
26566
  return function () {
26572
- const testBed = getTestBed();
26567
+ const testBed = TestBedImpl.INSTANCE;
26573
26568
  if (moduleDef) {
26574
26569
  testBed.configureTestingModule(moduleDef);
26575
26570
  }
@@ -26599,9 +26594,9 @@ if (_global.afterEach) {
26599
26594
  }
26600
26595
  function getCleanupHook(expectedTeardownValue) {
26601
26596
  return () => {
26602
- // TODO(alxhub): find a better type here
26603
- if (TestBed.shouldTearDownTestingModule() === expectedTeardownValue) {
26604
- TestBed.resetTestingModule();
26597
+ const testBed = TestBedImpl.INSTANCE;
26598
+ if (testBed.shouldTearDownTestingModule() === expectedTeardownValue) {
26599
+ testBed.resetTestingModule();
26605
26600
  resetFakeAsyncZone();
26606
26601
  }
26607
26602
  };