@angular/core 13.1.0-next.2 → 13.1.2

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 (81) hide show
  1. package/core.d.ts +77 -672
  2. package/esm2020/src/application_module.mjs +2 -4
  3. package/esm2020/src/application_ref.mjs +45 -46
  4. package/esm2020/src/change_detection/change_detector_ref.mjs +9 -6
  5. package/esm2020/src/core.mjs +1 -2
  6. package/esm2020/src/core_private_export.mjs +4 -4
  7. package/esm2020/src/core_render3_private_export.mjs +4 -17
  8. package/esm2020/src/debug/debug_node.mjs +10 -129
  9. package/esm2020/src/di/injectable.mjs +11 -20
  10. package/esm2020/src/di/injector.mjs +6 -268
  11. package/esm2020/src/di/metadata_attr.mjs +2 -9
  12. package/esm2020/src/di/reflective_injector.mjs +3 -1
  13. package/esm2020/src/error_details_base_url.mjs +16 -0
  14. package/esm2020/src/error_handler.mjs +2 -10
  15. package/esm2020/src/errors.mjs +18 -15
  16. package/esm2020/src/linker/compiler.mjs +33 -50
  17. package/esm2020/src/linker/component_factory_resolver.mjs +1 -38
  18. package/esm2020/src/linker/element_ref.mjs +9 -6
  19. package/esm2020/src/linker/ng_module_factory_loader.mjs +20 -24
  20. package/esm2020/src/linker/template_ref.mjs +4 -6
  21. package/esm2020/src/linker/view_container_ref.mjs +11 -6
  22. package/esm2020/src/metadata/directives.mjs +7 -17
  23. package/esm2020/src/metadata/ng_module.mjs +3 -18
  24. package/esm2020/src/metadata/view.mjs +12 -12
  25. package/esm2020/src/render/api.mjs +2 -6
  26. package/esm2020/src/render3/di_setup.mjs +6 -3
  27. package/esm2020/src/render3/errors.mjs +4 -6
  28. package/esm2020/src/render3/errors_di.mjs +11 -4
  29. package/esm2020/src/render3/i18n/i18n_parse.mjs +2 -2
  30. package/esm2020/src/render3/instructions/element.mjs +3 -3
  31. package/esm2020/src/render3/instructions/shared.mjs +4 -4
  32. package/esm2020/src/render3/ng_module_ref.mjs +5 -9
  33. package/esm2020/src/render3/pipe.mjs +12 -4
  34. package/esm2020/src/util/errors.mjs +10 -3
  35. package/esm2020/src/version.mjs +1 -1
  36. package/esm2020/src/view/index.mjs +1 -15
  37. package/esm2020/testing/src/logger.mjs +3 -3
  38. package/esm2020/testing/src/metadata_overrider.mjs +14 -2
  39. package/esm2020/testing/src/ng_zone_mock.mjs +3 -3
  40. package/esm2020/testing/src/test_bed.mjs +3 -526
  41. package/esm2020/testing/src/test_hooks.mjs +3 -3
  42. package/esm2020/testing/src/testing.mjs +1 -2
  43. package/fesm2015/core.mjs +355 -4848
  44. package/fesm2015/core.mjs.map +1 -1
  45. package/fesm2015/testing.mjs +26 -607
  46. package/fesm2015/testing.mjs.map +1 -1
  47. package/fesm2020/core.mjs +353 -4847
  48. package/fesm2020/core.mjs.map +1 -1
  49. package/fesm2020/testing.mjs +25 -608
  50. package/fesm2020/testing.mjs.map +1 -1
  51. package/package.json +1 -1
  52. package/schematics/migrations/entry-components/index.d.ts +11 -0
  53. package/schematics/migrations/entry-components/index.js +71 -0
  54. package/schematics/migrations/entry-components/util.d.ts +16 -0
  55. package/schematics/migrations/entry-components/util.js +57 -0
  56. package/schematics/migrations.json +10 -0
  57. package/schematics/utils/import_manager.js +14 -3
  58. package/schematics/utils/typescript/imports.js +9 -3
  59. package/testing/testing.d.ts +2 -47
  60. package/esm2020/src/codegen_private_exports.mjs +0 -11
  61. package/esm2020/src/debug/proxy.mjs +0 -23
  62. package/esm2020/src/ivy_switch.mjs +0 -11
  63. package/esm2020/src/render3/error_code.mjs +0 -42
  64. package/esm2020/src/render3/error_details_base_url.mjs +0 -16
  65. package/esm2020/src/view/element.mjs +0 -296
  66. package/esm2020/src/view/entrypoint.mjs +0 -63
  67. package/esm2020/src/view/errors.mjs +0 -43
  68. package/esm2020/src/view/ng_content.mjs +0 -47
  69. package/esm2020/src/view/ng_module.mjs +0 -215
  70. package/esm2020/src/view/provider.mjs +0 -490
  71. package/esm2020/src/view/pure_expression.mjs +0 -220
  72. package/esm2020/src/view/query.mjs +0 -180
  73. package/esm2020/src/view/refs.mjs +0 -369
  74. package/esm2020/src/view/services.mjs +0 -751
  75. package/esm2020/src/view/text.mjs +0 -136
  76. package/esm2020/src/view/types.mjs +0 -108
  77. package/esm2020/src/view/util.mjs +0 -369
  78. package/esm2020/src/view/view.mjs +0 -629
  79. package/esm2020/src/view/view_attach.mjs +0 -114
  80. package/esm2020/testing/src/private_export_testing.mjs +0 -9
  81. package/esm2020/testing/src/test_compiler.mjs +0 -69
@@ -1,12 +1,10 @@
1
1
  /**
2
- * @license Angular v13.1.0-next.2
3
- * (c) 2010-2021 Google LLC. https://angular.io/
2
+ * @license Angular v13.1.2
3
+ * (c) 2010-2022 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
6
 
7
- import * as i0 from '@angular/core';
8
- import { getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵ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, Injector, InjectFlags, ɵresetCompiledComponents, ɵflushModuleScopingQueueAsMuchAsPossible, Injectable, ɵclearOverrides, ɵoverrideComponentView, ɵINJECTOR_SCOPE, Optional, SkipSelf, ɵoverrideProvider, ɵivyEnabled } from '@angular/core';
9
- import { __decorate } from 'tslib';
7
+ import { getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵRender3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵ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, Injector, InjectFlags, ɵresetCompiledComponents, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
10
8
  import { ResourceLoader } from '@angular/compiler';
11
9
 
12
10
  /**
@@ -606,8 +604,20 @@ function setMetadata(metadata, set) {
606
604
  }
607
605
  }
608
606
  function _propHashKey(propName, propValue, references) {
607
+ let nextObjectId = 0;
608
+ const objectIds = new Map();
609
609
  const replacer = (key, value) => {
610
- if (typeof value === 'function') {
610
+ if (value !== null && typeof value === 'object') {
611
+ if (objectIds.has(value)) {
612
+ return objectIds.get(value);
613
+ }
614
+ // Record an id for this object such that any later references use the object's id instead
615
+ // of the object itself, in order to break cyclic pointers in objects.
616
+ objectIds.set(value, `ɵobj#${nextObjectId++}`);
617
+ // The first time an object is seen the object itself is serialized.
618
+ return value;
619
+ }
620
+ else if (typeof value === 'function') {
611
621
  value = _serializeReference(value, references);
612
622
  }
613
623
  return value;
@@ -1492,7 +1502,7 @@ const ComponentFixtureNoNgZone = new InjectionToken('ComponentFixtureNoNgZone');
1492
1502
  * Use of this source code is governed by an MIT-style license that can be
1493
1503
  * found in the LICENSE file at https://angular.io/license
1494
1504
  */
1495
- let _nextRootElementId$1 = 0;
1505
+ let _nextRootElementId = 0;
1496
1506
  /**
1497
1507
  * @description
1498
1508
  * Configures and initializes environment for unit testing and provides methods for
@@ -1739,7 +1749,7 @@ class TestBedRender3 {
1739
1749
  }
1740
1750
  createComponent(type) {
1741
1751
  const testComponentRenderer = this.inject(TestComponentRenderer);
1742
- const rootElId = `root${_nextRootElementId$1++}`;
1752
+ const rootElId = `root${_nextRootElementId++}`;
1743
1753
  testComponentRenderer.insertRootElement(rootElId);
1744
1754
  const componentDef = type.ɵcmp;
1745
1755
  if (!componentDef) {
@@ -1868,76 +1878,9 @@ class TestBedRender3 {
1868
1878
  }
1869
1879
  }
1870
1880
  }
1871
- let testBed$1;
1881
+ let testBed;
1872
1882
  function _getTestBedRender3() {
1873
- return testBed$1 = testBed$1 || new TestBedRender3();
1874
- }
1875
-
1876
- /**
1877
- * @license
1878
- * Copyright Google LLC All Rights Reserved.
1879
- *
1880
- * Use of this source code is governed by an MIT-style license that can be
1881
- * found in the LICENSE file at https://angular.io/license
1882
- */
1883
- function unimplemented() {
1884
- throw Error('unimplemented');
1885
- }
1886
- /**
1887
- * Special interface to the compiler only used by testing
1888
- *
1889
- * @publicApi
1890
- */
1891
- class TestingCompiler extends Compiler {
1892
- get injector() {
1893
- throw unimplemented();
1894
- }
1895
- overrideModule(module, overrides) {
1896
- throw unimplemented();
1897
- }
1898
- overrideDirective(directive, overrides) {
1899
- throw unimplemented();
1900
- }
1901
- overrideComponent(component, overrides) {
1902
- throw unimplemented();
1903
- }
1904
- overridePipe(directive, overrides) {
1905
- throw unimplemented();
1906
- }
1907
- /**
1908
- * Allows to pass the compile summary from AOT compilation to the JIT compiler,
1909
- * so that it can use the code generated by AOT.
1910
- */
1911
- loadAotSummaries(summaries) {
1912
- throw unimplemented();
1913
- }
1914
- /**
1915
- * Gets the component factory for the given component.
1916
- * This assumes that the component has been compiled before calling this call using
1917
- * `compileModuleAndAllComponents*`.
1918
- */
1919
- getComponentFactory(component) {
1920
- throw unimplemented();
1921
- }
1922
- /**
1923
- * Returns the component type that is stored in the given error.
1924
- * This can be used for errors created by compileModule...
1925
- */
1926
- getComponentFromError(error) {
1927
- throw unimplemented();
1928
- }
1929
- }
1930
- TestingCompiler.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.0-next.2", ngImport: i0, type: TestingCompiler, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1931
- TestingCompiler.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.1.0-next.2", ngImport: i0, type: TestingCompiler });
1932
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.1.0-next.2", ngImport: i0, type: TestingCompiler, decorators: [{
1933
- type: Injectable
1934
- }] });
1935
- /**
1936
- * A factory for creating a Compiler
1937
- *
1938
- * @publicApi
1939
- */
1940
- class TestingCompilerFactory {
1883
+ return testBed = testBed || new TestBedRender3();
1941
1884
  }
1942
1885
 
1943
1886
  /**
@@ -1947,520 +1890,6 @@ class TestingCompilerFactory {
1947
1890
  * Use of this source code is governed by an MIT-style license that can be
1948
1891
  * found in the LICENSE file at https://angular.io/license
1949
1892
  */
1950
- let _nextRootElementId = 0;
1951
- /**
1952
- * @description
1953
- * Configures and initializes environment for unit testing and provides methods for
1954
- * creating components and services in unit tests.
1955
- *
1956
- * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
1957
- *
1958
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
1959
- * according to the compiler used.
1960
- */
1961
- class TestBedViewEngine {
1962
- constructor() {
1963
- this._instantiated = false;
1964
- this._compiler = null;
1965
- this._moduleRef = null;
1966
- this._moduleFactory = null;
1967
- this._pendingModuleFactory = null;
1968
- this._compilerOptions = [];
1969
- this._moduleOverrides = [];
1970
- this._componentOverrides = [];
1971
- this._directiveOverrides = [];
1972
- this._pipeOverrides = [];
1973
- this._providers = [];
1974
- this._declarations = [];
1975
- this._imports = [];
1976
- this._schemas = [];
1977
- this._activeFixtures = [];
1978
- this._testEnvAotSummaries = () => [];
1979
- this._aotSummaries = [];
1980
- this._templateOverrides = [];
1981
- this._isRoot = true;
1982
- this._rootProviderOverrides = [];
1983
- this.platform = null;
1984
- this.ngModule = null;
1985
- }
1986
- /**
1987
- * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
1988
- * angular module. These are common to every test in the suite.
1989
- *
1990
- * This may only be called once, to set up the common providers for the current test
1991
- * suite on the current platform. If you absolutely need to change the providers,
1992
- * first use `resetTestEnvironment`.
1993
- *
1994
- * Test modules and platforms for individual platforms are available from
1995
- * '@angular/<platform_name>/testing'.
1996
- */
1997
- static initTestEnvironment(ngModule, platform, summariesOrOptions) {
1998
- const testBed = _getTestBedViewEngine();
1999
- testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
2000
- return testBed;
2001
- }
2002
- /**
2003
- * Reset the providers for the test injector.
2004
- */
2005
- static resetTestEnvironment() {
2006
- _getTestBedViewEngine().resetTestEnvironment();
2007
- }
2008
- static resetTestingModule() {
2009
- _getTestBedViewEngine().resetTestingModule();
2010
- return TestBedViewEngine;
2011
- }
2012
- /**
2013
- * Allows overriding default compiler providers and settings
2014
- * which are defined in test_injector.js
2015
- */
2016
- static configureCompiler(config) {
2017
- _getTestBedViewEngine().configureCompiler(config);
2018
- return TestBedViewEngine;
2019
- }
2020
- /**
2021
- * Allows overriding default providers, directives, pipes, modules of the test injector,
2022
- * which are defined in test_injector.js
2023
- */
2024
- static configureTestingModule(moduleDef) {
2025
- _getTestBedViewEngine().configureTestingModule(moduleDef);
2026
- return TestBedViewEngine;
2027
- }
2028
- /**
2029
- * Compile components with a `templateUrl` for the test's NgModule.
2030
- * It is necessary to call this function
2031
- * as fetching urls is asynchronous.
2032
- */
2033
- static compileComponents() {
2034
- return getTestBed().compileComponents();
2035
- }
2036
- static overrideModule(ngModule, override) {
2037
- _getTestBedViewEngine().overrideModule(ngModule, override);
2038
- return TestBedViewEngine;
2039
- }
2040
- static overrideComponent(component, override) {
2041
- _getTestBedViewEngine().overrideComponent(component, override);
2042
- return TestBedViewEngine;
2043
- }
2044
- static overrideDirective(directive, override) {
2045
- _getTestBedViewEngine().overrideDirective(directive, override);
2046
- return TestBedViewEngine;
2047
- }
2048
- static overridePipe(pipe, override) {
2049
- _getTestBedViewEngine().overridePipe(pipe, override);
2050
- return TestBedViewEngine;
2051
- }
2052
- static overrideTemplate(component, template) {
2053
- _getTestBedViewEngine().overrideComponent(component, { set: { template, templateUrl: null } });
2054
- return TestBedViewEngine;
2055
- }
2056
- /**
2057
- * Overrides the template of the given component, compiling the template
2058
- * in the context of the TestingModule.
2059
- *
2060
- * Note: This works for JIT and AOTed components as well.
2061
- */
2062
- static overrideTemplateUsingTestingModule(component, template) {
2063
- _getTestBedViewEngine().overrideTemplateUsingTestingModule(component, template);
2064
- return TestBedViewEngine;
2065
- }
2066
- static overrideProvider(token, provider) {
2067
- _getTestBedViewEngine().overrideProvider(token, provider);
2068
- return TestBedViewEngine;
2069
- }
2070
- static inject(token, notFoundValue, flags) {
2071
- return _getTestBedViewEngine().inject(token, notFoundValue, flags);
2072
- }
2073
- /** @deprecated from v9.0.0 use TestBed.inject */
2074
- static get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
2075
- return _getTestBedViewEngine().inject(token, notFoundValue, flags);
2076
- }
2077
- static createComponent(component) {
2078
- return _getTestBedViewEngine().createComponent(component);
2079
- }
2080
- static shouldTearDownTestingModule() {
2081
- return _getTestBedViewEngine().shouldTearDownTestingModule();
2082
- }
2083
- static tearDownTestingModule() {
2084
- _getTestBedViewEngine().tearDownTestingModule();
2085
- }
2086
- /**
2087
- * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
2088
- * angular module. These are common to every test in the suite.
2089
- *
2090
- * This may only be called once, to set up the common providers for the current test
2091
- * suite on the current platform. If you absolutely need to change the providers,
2092
- * first use `resetTestEnvironment`.
2093
- *
2094
- * Test modules and platforms for individual platforms are available from
2095
- * '@angular/<platform_name>/testing'.
2096
- */
2097
- initTestEnvironment(ngModule, platform, summariesOrOptions) {
2098
- if (this.platform || this.ngModule) {
2099
- throw new Error('Cannot set base providers because it has already been called');
2100
- }
2101
- this.platform = platform;
2102
- this.ngModule = ngModule;
2103
- if (typeof summariesOrOptions === 'function') {
2104
- this._testEnvAotSummaries = summariesOrOptions;
2105
- TestBedViewEngine._environmentTeardownOptions = undefined;
2106
- }
2107
- else {
2108
- this._testEnvAotSummaries = (summariesOrOptions?.aotSummaries) || (() => []);
2109
- TestBedViewEngine._environmentTeardownOptions = summariesOrOptions?.teardown;
2110
- }
2111
- }
2112
- /**
2113
- * Reset the providers for the test injector.
2114
- */
2115
- resetTestEnvironment() {
2116
- this.resetTestingModule();
2117
- this.platform = null;
2118
- this.ngModule = null;
2119
- this._testEnvAotSummaries = () => [];
2120
- TestBedViewEngine._environmentTeardownOptions = undefined;
2121
- }
2122
- resetTestingModule() {
2123
- ɵclearOverrides();
2124
- this._aotSummaries = [];
2125
- this._templateOverrides = [];
2126
- this._compiler = null;
2127
- this._moduleOverrides = [];
2128
- this._componentOverrides = [];
2129
- this._directiveOverrides = [];
2130
- this._pipeOverrides = [];
2131
- this._isRoot = true;
2132
- this._rootProviderOverrides = [];
2133
- this._moduleFactory = null;
2134
- this._pendingModuleFactory = null;
2135
- this._compilerOptions = [];
2136
- this._providers = [];
2137
- this._declarations = [];
2138
- this._imports = [];
2139
- this._schemas = [];
2140
- // We have to chain a couple of try/finally blocks, because each step can
2141
- // throw errors and we don't want it to interrupt the next step and we also
2142
- // want an error to be thrown at the end.
2143
- try {
2144
- this.destroyActiveFixtures();
2145
- }
2146
- finally {
2147
- try {
2148
- if (this.shouldTearDownTestingModule()) {
2149
- this.tearDownTestingModule();
2150
- }
2151
- }
2152
- finally {
2153
- this._moduleRef = null;
2154
- this._instanceTeardownOptions = undefined;
2155
- this._instantiated = false;
2156
- }
2157
- }
2158
- }
2159
- configureCompiler(config) {
2160
- this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
2161
- this._compilerOptions.push(config);
2162
- }
2163
- configureTestingModule(moduleDef) {
2164
- this._assertNotInstantiated('TestBed.configureTestingModule', 'configure the test module');
2165
- if (moduleDef.providers) {
2166
- this._providers.push(...moduleDef.providers);
2167
- }
2168
- if (moduleDef.declarations) {
2169
- this._declarations.push(...moduleDef.declarations);
2170
- }
2171
- if (moduleDef.imports) {
2172
- this._imports.push(...moduleDef.imports);
2173
- }
2174
- if (moduleDef.schemas) {
2175
- this._schemas.push(...moduleDef.schemas);
2176
- }
2177
- if (moduleDef.aotSummaries) {
2178
- this._aotSummaries.push(moduleDef.aotSummaries);
2179
- }
2180
- // Always re-assign the teardown options, even if they're undefined.
2181
- // This ensures that we don't carry the options between tests.
2182
- this._instanceTeardownOptions = moduleDef.teardown;
2183
- }
2184
- compileComponents() {
2185
- if (this._moduleFactory || this._instantiated) {
2186
- return Promise.resolve(null);
2187
- }
2188
- const moduleType = this._createCompilerAndModule();
2189
- this._pendingModuleFactory = moduleType;
2190
- return this._compiler.compileModuleAndAllComponentsAsync(moduleType).then(result => {
2191
- // If the module mismatches by the time the promise resolves, it means that the module has
2192
- // already been destroyed and a new compilation has started. If that's the case, avoid
2193
- // overwriting the module factory, because it can cause downstream errors.
2194
- if (this._pendingModuleFactory === moduleType) {
2195
- this._moduleFactory = result.ngModuleFactory;
2196
- this._pendingModuleFactory = null;
2197
- }
2198
- });
2199
- }
2200
- _initIfNeeded() {
2201
- if (this._instantiated) {
2202
- return;
2203
- }
2204
- if (!this._moduleFactory) {
2205
- try {
2206
- const moduleType = this._createCompilerAndModule();
2207
- this._moduleFactory =
2208
- this._compiler.compileModuleAndAllComponentsSync(moduleType).ngModuleFactory;
2209
- }
2210
- catch (e) {
2211
- const errorCompType = this._compiler.getComponentFromError(e);
2212
- if (errorCompType) {
2213
- throw new Error(`This test module uses the component ${ɵstringify(errorCompType)} which is using a "templateUrl" or "styleUrls", but they were never compiled. ` +
2214
- `Please call "TestBed.compileComponents" before your test.`);
2215
- }
2216
- else {
2217
- throw e;
2218
- }
2219
- }
2220
- }
2221
- for (const { component, templateOf } of this._templateOverrides) {
2222
- const compFactory = this._compiler.getComponentFactory(templateOf);
2223
- ɵoverrideComponentView(component, compFactory);
2224
- }
2225
- const ngZone = new NgZone({ enableLongStackTrace: true, shouldCoalesceEventChangeDetection: false });
2226
- const providers = [{ provide: NgZone, useValue: ngZone }];
2227
- const ngZoneInjector = Injector.create({
2228
- providers: providers,
2229
- parent: this.platform.injector,
2230
- name: this._moduleFactory.moduleType.name
2231
- });
2232
- this._moduleRef = this._moduleFactory.create(ngZoneInjector);
2233
- // ApplicationInitStatus.runInitializers() is marked @internal to core. So casting to any
2234
- // before accessing it.
2235
- try {
2236
- this._moduleRef.injector.get(ApplicationInitStatus).runInitializers();
2237
- }
2238
- finally {
2239
- this._instantiated = true;
2240
- }
2241
- }
2242
- _createCompilerAndModule() {
2243
- const providers = this._providers.concat([{ provide: TestBed, useValue: this }]);
2244
- const declarations = [...this._declarations, ...this._templateOverrides.map(entry => entry.templateOf)];
2245
- const rootScopeImports = [];
2246
- const rootProviderOverrides = this._rootProviderOverrides;
2247
- if (this._isRoot) {
2248
- let RootScopeModule = class RootScopeModule {
2249
- };
2250
- RootScopeModule = __decorate([
2251
- NgModule({
2252
- providers: [
2253
- ...rootProviderOverrides,
2254
- ],
2255
- jit: true,
2256
- })
2257
- ], RootScopeModule);
2258
- rootScopeImports.push(RootScopeModule);
2259
- }
2260
- providers.push({ provide: ɵINJECTOR_SCOPE, useValue: this._isRoot ? 'root' : null });
2261
- const imports = [rootScopeImports, this.ngModule, this._imports];
2262
- const schemas = this._schemas;
2263
- let DynamicTestModule = class DynamicTestModule {
2264
- };
2265
- DynamicTestModule = __decorate([
2266
- NgModule({ providers, declarations, imports, schemas, jit: true })
2267
- ], DynamicTestModule);
2268
- const compilerFactory = this.platform.injector.get(TestingCompilerFactory);
2269
- this._compiler = compilerFactory.createTestingCompiler(this._compilerOptions);
2270
- for (const summary of [this._testEnvAotSummaries, ...this._aotSummaries]) {
2271
- this._compiler.loadAotSummaries(summary);
2272
- }
2273
- this._moduleOverrides.forEach((entry) => this._compiler.overrideModule(entry[0], entry[1]));
2274
- this._componentOverrides.forEach((entry) => this._compiler.overrideComponent(entry[0], entry[1]));
2275
- this._directiveOverrides.forEach((entry) => this._compiler.overrideDirective(entry[0], entry[1]));
2276
- this._pipeOverrides.forEach((entry) => this._compiler.overridePipe(entry[0], entry[1]));
2277
- return DynamicTestModule;
2278
- }
2279
- _assertNotInstantiated(methodName, methodDescription) {
2280
- if (this._instantiated) {
2281
- throw new Error(`Cannot ${methodDescription} when the test module has already been instantiated. ` +
2282
- `Make sure you are not using \`inject\` before \`${methodName}\`.`);
2283
- }
2284
- }
2285
- inject(token, notFoundValue, flags) {
2286
- this._initIfNeeded();
2287
- if (token === TestBed) {
2288
- return this;
2289
- }
2290
- // Tests can inject things from the ng module and from the compiler,
2291
- // but the ng module can't inject things from the compiler and vice versa.
2292
- const UNDEFINED = {};
2293
- const result = this._moduleRef.injector.get(token, UNDEFINED, flags);
2294
- return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue, flags) :
2295
- result;
2296
- }
2297
- /** @deprecated from v9.0.0 use TestBed.inject */
2298
- get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
2299
- return this.inject(token, notFoundValue, flags);
2300
- }
2301
- execute(tokens, fn, context) {
2302
- this._initIfNeeded();
2303
- const params = tokens.map(t => this.inject(t));
2304
- return fn.apply(context, params);
2305
- }
2306
- overrideModule(ngModule, override) {
2307
- this._assertNotInstantiated('overrideModule', 'override module metadata');
2308
- this._moduleOverrides.push([ngModule, override]);
2309
- }
2310
- overrideComponent(component, override) {
2311
- this._assertNotInstantiated('overrideComponent', 'override component metadata');
2312
- this._componentOverrides.push([component, override]);
2313
- }
2314
- overrideDirective(directive, override) {
2315
- this._assertNotInstantiated('overrideDirective', 'override directive metadata');
2316
- this._directiveOverrides.push([directive, override]);
2317
- }
2318
- overridePipe(pipe, override) {
2319
- this._assertNotInstantiated('overridePipe', 'override pipe metadata');
2320
- this._pipeOverrides.push([pipe, override]);
2321
- }
2322
- overrideProvider(token, provider) {
2323
- this._assertNotInstantiated('overrideProvider', 'override provider');
2324
- this.overrideProviderImpl(token, provider);
2325
- }
2326
- overrideProviderImpl(token, provider, deprecated = false) {
2327
- let def = null;
2328
- if (typeof token !== 'string' && (def = ɵgetInjectableDef(token)) && def.providedIn === 'root') {
2329
- if (provider.useFactory) {
2330
- this._rootProviderOverrides.push({ provide: token, useFactory: provider.useFactory, deps: provider.deps || [] });
2331
- }
2332
- else {
2333
- this._rootProviderOverrides.push({ provide: token, useValue: provider.useValue });
2334
- }
2335
- }
2336
- let flags = 0;
2337
- let value;
2338
- if (provider.useFactory) {
2339
- flags |= 1024 /* TypeFactoryProvider */;
2340
- value = provider.useFactory;
2341
- }
2342
- else {
2343
- flags |= 256 /* TypeValueProvider */;
2344
- value = provider.useValue;
2345
- }
2346
- const deps = (provider.deps || []).map((dep) => {
2347
- let depFlags = 0 /* None */;
2348
- let depToken;
2349
- if (Array.isArray(dep)) {
2350
- dep.forEach((entry) => {
2351
- if (entry instanceof Optional) {
2352
- depFlags |= 2 /* Optional */;
2353
- }
2354
- else if (entry instanceof SkipSelf) {
2355
- depFlags |= 1 /* SkipSelf */;
2356
- }
2357
- else {
2358
- depToken = entry;
2359
- }
2360
- });
2361
- }
2362
- else {
2363
- depToken = dep;
2364
- }
2365
- return [depFlags, depToken];
2366
- });
2367
- ɵoverrideProvider({ token, flags, deps, value, deprecatedBehavior: deprecated });
2368
- }
2369
- overrideTemplateUsingTestingModule(component, template) {
2370
- this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template');
2371
- let OverrideComponent = class OverrideComponent {
2372
- };
2373
- OverrideComponent = __decorate([
2374
- Component({ selector: 'empty', template, jit: true })
2375
- ], OverrideComponent);
2376
- this._templateOverrides.push({ component, templateOf: OverrideComponent });
2377
- }
2378
- createComponent(component) {
2379
- this._initIfNeeded();
2380
- const componentFactory = this._compiler.getComponentFactory(component);
2381
- if (!componentFactory) {
2382
- throw new Error(`Cannot create the component ${ɵstringify(component)} as it was not imported into the testing module!`);
2383
- }
2384
- // TODO: Don't cast as `InjectionToken<boolean>`, declared type is boolean[]
2385
- const noNgZone = this.inject(ComponentFixtureNoNgZone, false);
2386
- // TODO: Don't cast as `InjectionToken<boolean>`, declared type is boolean[]
2387
- const autoDetect = this.inject(ComponentFixtureAutoDetect, false);
2388
- const ngZone = noNgZone ? null : this.inject(NgZone, null);
2389
- const testComponentRenderer = this.inject(TestComponentRenderer);
2390
- const rootElId = `root${_nextRootElementId++}`;
2391
- testComponentRenderer.insertRootElement(rootElId);
2392
- const initComponent = () => {
2393
- const componentRef = componentFactory.create(Injector.NULL, [], `#${rootElId}`, this._moduleRef);
2394
- return new ComponentFixture(componentRef, ngZone, autoDetect);
2395
- };
2396
- const fixture = !ngZone ? initComponent() : ngZone.run(initComponent);
2397
- this._activeFixtures.push(fixture);
2398
- return fixture;
2399
- }
2400
- destroyActiveFixtures() {
2401
- let errorCount = 0;
2402
- this._activeFixtures.forEach((fixture) => {
2403
- try {
2404
- fixture.destroy();
2405
- }
2406
- catch (e) {
2407
- errorCount++;
2408
- console.error('Error during cleanup of component', {
2409
- component: fixture.componentInstance,
2410
- stacktrace: e,
2411
- });
2412
- }
2413
- });
2414
- this._activeFixtures = [];
2415
- if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
2416
- throw Error(`${errorCount} ${(errorCount === 1 ? 'component' : 'components')} ` +
2417
- `threw errors during cleanup`);
2418
- }
2419
- }
2420
- shouldRethrowTeardownErrors() {
2421
- const instanceOptions = this._instanceTeardownOptions;
2422
- const environmentOptions = TestBedViewEngine._environmentTeardownOptions;
2423
- // If the new teardown behavior hasn't been configured, preserve the old behavior.
2424
- if (!instanceOptions && !environmentOptions) {
2425
- return TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
2426
- }
2427
- // Otherwise use the configured behavior or default to rethrowing.
2428
- return instanceOptions?.rethrowErrors ?? environmentOptions?.rethrowErrors ??
2429
- this.shouldTearDownTestingModule();
2430
- }
2431
- shouldTearDownTestingModule() {
2432
- return this._instanceTeardownOptions?.destroyAfterEach ??
2433
- TestBedViewEngine._environmentTeardownOptions?.destroyAfterEach ??
2434
- TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
2435
- }
2436
- tearDownTestingModule() {
2437
- // If the module ref has already been destroyed, we won't be able to get a test renderer.
2438
- if (this._moduleRef === null) {
2439
- return;
2440
- }
2441
- // Resolve the renderer ahead of time, because we want to remove the root elements as the very
2442
- // last step, but the injector will be destroyed as a part of the module ref destruction.
2443
- const testRenderer = this.inject(TestComponentRenderer);
2444
- try {
2445
- this._moduleRef.destroy();
2446
- }
2447
- catch (e) {
2448
- if (this._instanceTeardownOptions?.rethrowErrors ??
2449
- TestBedViewEngine._environmentTeardownOptions?.rethrowErrors ?? true) {
2450
- throw e;
2451
- }
2452
- else {
2453
- console.error('Error during cleanup of a testing module', {
2454
- component: this._moduleRef.instance,
2455
- stacktrace: e,
2456
- });
2457
- }
2458
- }
2459
- finally {
2460
- testRenderer?.removeAllRootElements?.();
2461
- }
2462
- }
2463
- }
2464
1893
  /**
2465
1894
  * @description
2466
1895
  * Configures and initializes environment for unit testing and provides methods for
@@ -2473,7 +1902,7 @@ class TestBedViewEngine {
2473
1902
  *
2474
1903
  * @publicApi
2475
1904
  */
2476
- const TestBed = ɵivyEnabled ? TestBedRender3 : TestBedViewEngine;
1905
+ const TestBed = TestBedRender3;
2477
1906
  /**
2478
1907
  * Returns a singleton of the applicable `TestBed`.
2479
1908
  *
@@ -2481,11 +1910,7 @@ const TestBed = ɵivyEnabled ? TestBedRender3 : TestBedViewEngine;
2481
1910
  *
2482
1911
  * @publicApi
2483
1912
  */
2484
- const getTestBed = ɵivyEnabled ? _getTestBedRender3 : _getTestBedViewEngine;
2485
- let testBed;
2486
- function _getTestBedViewEngine() {
2487
- return testBed = testBed || new TestBedViewEngine();
2488
- }
1913
+ const getTestBed = _getTestBedRender3;
2489
1914
  /**
2490
1915
  * Allows injecting dependencies in `beforeEach()` and `it()`.
2491
1916
  *
@@ -2568,8 +1993,8 @@ if (_global.afterEach) {
2568
1993
  }
2569
1994
  function getCleanupHook(expectedTeardownValue) {
2570
1995
  return () => {
2571
- if (TestBed.shouldTearDownTestingModule() ===
2572
- expectedTeardownValue) {
1996
+ // TODO(alxhub): find a better type here
1997
+ if (TestBed.shouldTearDownTestingModule() === expectedTeardownValue) {
2573
1998
  TestBed.resetTestingModule();
2574
1999
  resetFakeAsyncZone();
2575
2000
  }
@@ -2602,14 +2027,6 @@ const __core_private_testing_placeholder__ = '';
2602
2027
  * found in the LICENSE file at https://angular.io/license
2603
2028
  */
2604
2029
 
2605
- /**
2606
- * @license
2607
- * Copyright Google LLC All Rights Reserved.
2608
- *
2609
- * Use of this source code is governed by an MIT-style license that can be
2610
- * found in the LICENSE file at https://angular.io/license
2611
- */
2612
-
2613
2030
  /**
2614
2031
  * @license
2615
2032
  * Copyright Google LLC All Rights Reserved.
@@ -2631,5 +2048,5 @@ const __core_private_testing_placeholder__ = '';
2631
2048
  * Generated bundle index. Do not edit.
2632
2049
  */
2633
2050
 
2634
- export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider, TestingCompiler as ɵTestingCompiler, TestingCompilerFactory as ɵTestingCompilerFactory };
2051
+ export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, async, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, MetadataOverrider as ɵMetadataOverrider };
2635
2052
  //# sourceMappingURL=testing.mjs.map