@angular/core 20.0.0-next.1 → 20.0.0-next.3
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.
- package/fesm2022/core.mjs +770 -2144
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/di.mjs +3 -2
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +2 -589
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +44 -13
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +7 -39
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +116 -143
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/weak_ref-DrMdAIDh.mjs +12 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +1 -0
- package/index.d.ts +14366 -15214
- package/navigation_types.d-u4EOrrdZ.d.ts +121 -0
- package/package.json +2 -2
- package/primitives/di/index.d.ts +66 -59
- package/primitives/event-dispatch/index.d.ts +205 -309
- package/primitives/signals/index.d.ts +161 -195
- package/rxjs-interop/index.d.ts +71 -100
- package/schematics/bundles/{apply_import_manager-e2a7fe5b.js → apply_import_manager-BXQEjo09.js} +15 -19
- package/schematics/bundles/{checker-af521da6.js → checker-BHb19MHt.js} +3695 -1175
- package/schematics/bundles/cleanup-unused-imports.js +56 -89
- package/schematics/bundles/{compiler_host-5a29293c.js → compiler_host-Bk3repE2.js} +19 -23
- package/schematics/bundles/control-flow-migration.js +81 -38
- package/schematics/bundles/{imports-047fbbc8.js → imports-CIX-JgAN.js} +9 -14
- package/schematics/bundles/{index-1bef3025.js → index-BL9kAIe5.js} +62 -66
- package/schematics/bundles/{program-a449f9bf.js → index-I8VbxQcO.js} +1508 -3178
- package/schematics/bundles/inject-flags.js +147 -0
- package/schematics/bundles/inject-migration.js +121 -127
- package/schematics/bundles/{leading_space-f8944434.js → leading_space-D9nQ8UQC.js} +1 -1
- package/schematics/bundles/{migrate_ts_type_references-2a3e9e6b.js → migrate_ts_type_references-KlOTWeDl.js} +121 -126
- package/schematics/bundles/{ng_decorators-b0d8b324.js → ng_decorators-DznZ5jMl.js} +4 -8
- package/schematics/bundles/{nodes-7758dbf6.js → nodes-B16H9JUd.js} +2 -6
- package/schematics/bundles/output-migration.js +94 -128
- package/schematics/bundles/{project_tsconfig_paths-b558633b.js → project_tsconfig_paths-CDVxT6Ov.js} +1 -1
- package/schematics/bundles/{property_name-ac18447e.js → property_name-BBwFuqMe.js} +3 -7
- package/schematics/bundles/route-lazy-loading.js +35 -41
- package/schematics/bundles/{project_paths-17dc204d.js → run_in_devkit-C0JPtK2u.js} +283 -216
- package/schematics/bundles/self-closing-tags-migration.js +55 -91
- package/schematics/bundles/signal-input-migration.js +121 -156
- package/schematics/bundles/signal-queries-migration.js +119 -154
- package/schematics/bundles/signals.js +12 -14
- package/schematics/bundles/standalone-migration.js +180 -200
- package/schematics/bundles/symbol-VPWguRxr.js +25 -0
- package/schematics/bundles/test-bed-get.js +98 -0
- package/schematics/migrations.json +8 -14
- package/testing/index.d.ts +289 -471
- package/weak_ref.d-ttyj86RV.d.ts +9 -0
- package/schematics/bundles/explicit-standalone-flag.js +0 -184
- package/schematics/bundles/index-ef1bffbb.js +0 -30
- package/schematics/bundles/pending-tasks.js +0 -103
- package/schematics/bundles/provide-initializer.js +0 -186
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.0.0-next.
|
|
2
|
+
* @license Angular v20.0.0-next.3
|
|
3
3
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import * as i0 from '@angular/core';
|
|
8
|
-
import { ɵDeferBlockState, ɵtriggerResourceLoading, ɵrenderDeferBlockState, ɵCONTAINER_HEADER_OFFSET, ɵgetDeferBlocks
|
|
8
|
+
import { ɵDeferBlockState as _DeferBlockState, ɵtriggerResourceLoading as _triggerResourceLoading, ɵrenderDeferBlockState as _renderDeferBlockState, ɵCONTAINER_HEADER_OFFSET as _CONTAINER_HEADER_OFFSET, ɵgetDeferBlocks as _getDeferBlocks, InjectionToken, ɵDeferBlockBehavior as _DeferBlockBehavior, inject as inject$1, NgZone, ErrorHandler, Injectable, ɵNoopNgZone as _NoopNgZone, ApplicationRef, ɵPendingTasksInternal as _PendingTasksInternal, ɵZONELESS_ENABLED as _ZONELESS_ENABLED, ɵChangeDetectionScheduler as _ChangeDetectionScheduler, ɵEffectScheduler as _EffectScheduler, getDebugNode, RendererFactory2, ɵstringify as _stringify, Pipe, Directive, Component, NgModule, ɵReflectionCapabilities as _ReflectionCapabilities, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT as _USE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker as _depsTracker, ɵgetInjectableDef as _getInjectableDef, resolveForwardRef, ɵisComponentDefPendingResolution as _isComponentDefPendingResolution, ɵgetAsyncClassMetadataFn as _getAsyncClassMetadataFn, ɵresolveComponentResources as _resolveComponentResources, ɵRender3NgModuleRef as _Render3NgModuleRef, ApplicationInitStatus, LOCALE_ID, ɵDEFAULT_LOCALE_ID as _DEFAULT_LOCALE_ID, ɵsetLocaleId as _setLocaleId, ɵRender3ComponentFactory as _Render3ComponentFactory, ɵNG_COMP_DEF as _NG_COMP_DEF, ɵcompileComponent as _compileComponent, ɵNG_DIR_DEF as _NG_DIR_DEF, ɵcompileDirective as _compileDirective, ɵNG_PIPE_DEF as _NG_PIPE_DEF, ɵcompilePipe as _compilePipe, ɵNG_MOD_DEF as _NG_MOD_DEF, ɵpatchComponentDefWithScope as _patchComponentDefWithScope, ɵNG_INJ_DEF as _NG_INJ_DEF, ɵcompileNgModuleDefs as _compileNgModuleDefs, ɵclearResolutionOfComponentResourcesQueue as _clearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue as _restoreComponentResolutionQueue, ɵinternalProvideZoneChangeDetection as _internalProvideZoneChangeDetection, ɵChangeDetectionSchedulerImpl as _ChangeDetectionSchedulerImpl, Compiler, ɵDEFER_BLOCK_CONFIG as _DEFER_BLOCK_CONFIG, ɵINTERNAL_APPLICATION_ERROR_HANDLER as _INTERNAL_APPLICATION_ERROR_HANDLER, COMPILER_OPTIONS, Injector, ɵtransitiveScopesFor as _transitiveScopesFor, ɵgenerateStandaloneInDeclarationsError as _generateStandaloneInDeclarationsError, ɵNgModuleFactory as _NgModuleFactory, ModuleWithComponentFactories, ɵisEnvironmentProviders as _isEnvironmentProviders, ɵsetAllowDuplicateNgModuleIdsForTest as _setAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents as _resetCompiledComponents, ɵsetUnknownElementStrictMode as _setUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode as _setUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode as _getUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode as _getUnknownPropertyStrictMode, runInInjectionContext, EnvironmentInjector, ɵflushModuleScopingQueueAsMuchAsPossible as _flushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
9
9
|
export { ɵDeferBlockBehavior as DeferBlockBehavior, ɵDeferBlockState as DeferBlockState } from '@angular/core';
|
|
10
10
|
import { Subscription } from 'rxjs';
|
|
11
11
|
import { ResourceLoader } from '@angular/compiler';
|
|
@@ -68,13 +68,13 @@ class DeferBlockFixture {
|
|
|
68
68
|
throw new Error(`Tried to render this defer block in the \`${stateAsString}\` state, ` +
|
|
69
69
|
`but there was no @${stateAsString.toLowerCase()} block defined in a template.`);
|
|
70
70
|
}
|
|
71
|
-
if (state ===
|
|
72
|
-
await
|
|
71
|
+
if (state === _DeferBlockState.Complete) {
|
|
72
|
+
await _triggerResourceLoading(this.block.tDetails, this.block.lView, this.block.tNode);
|
|
73
73
|
}
|
|
74
74
|
// If the `render` method is used explicitly - skip timer-based scheduling for
|
|
75
75
|
// `@placeholder` and `@loading` blocks and render them immediately.
|
|
76
76
|
const skipTimerScheduling = true;
|
|
77
|
-
|
|
77
|
+
_renderDeferBlockState(state, this.block.tNode, this.block.lContainer, skipTimerScheduling);
|
|
78
78
|
this.componentFixture.detectChanges();
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
@@ -87,9 +87,9 @@ class DeferBlockFixture {
|
|
|
87
87
|
// located right after an LContainer header. Get a hold of that view and inspect
|
|
88
88
|
// it for nested defer blocks.
|
|
89
89
|
const deferBlockFixtures = [];
|
|
90
|
-
if (this.block.lContainer.length >=
|
|
91
|
-
const lView = this.block.lContainer[
|
|
92
|
-
|
|
90
|
+
if (this.block.lContainer.length >= _CONTAINER_HEADER_OFFSET) {
|
|
91
|
+
const lView = this.block.lContainer[_CONTAINER_HEADER_OFFSET];
|
|
92
|
+
_getDeferBlocks(lView, deferBlocks);
|
|
93
93
|
for (const block of deferBlocks) {
|
|
94
94
|
deferBlockFixtures.push(new DeferBlockFixture(block, this.componentFixture));
|
|
95
95
|
}
|
|
@@ -99,13 +99,13 @@ class DeferBlockFixture {
|
|
|
99
99
|
}
|
|
100
100
|
function hasStateTemplate(state, block) {
|
|
101
101
|
switch (state) {
|
|
102
|
-
case
|
|
102
|
+
case _DeferBlockState.Placeholder:
|
|
103
103
|
return block.tDetails.placeholderTmplIndex !== null;
|
|
104
|
-
case
|
|
104
|
+
case _DeferBlockState.Loading:
|
|
105
105
|
return block.tDetails.loadingTmplIndex !== null;
|
|
106
|
-
case
|
|
106
|
+
case _DeferBlockState.Error:
|
|
107
107
|
return block.tDetails.errorTmplIndex !== null;
|
|
108
|
-
case
|
|
108
|
+
case _DeferBlockState.Complete:
|
|
109
109
|
return true;
|
|
110
110
|
default:
|
|
111
111
|
return false;
|
|
@@ -113,11 +113,11 @@ function hasStateTemplate(state, block) {
|
|
|
113
113
|
}
|
|
114
114
|
function getDeferBlockStateNameFromEnum(state) {
|
|
115
115
|
switch (state) {
|
|
116
|
-
case
|
|
116
|
+
case _DeferBlockState.Placeholder:
|
|
117
117
|
return 'Placeholder';
|
|
118
|
-
case
|
|
118
|
+
case _DeferBlockState.Loading:
|
|
119
119
|
return 'Loading';
|
|
120
|
-
case
|
|
120
|
+
case _DeferBlockState.Error:
|
|
121
121
|
return 'Error';
|
|
122
122
|
default:
|
|
123
123
|
return 'Main';
|
|
@@ -131,7 +131,7 @@ const THROW_ON_UNKNOWN_ELEMENTS_DEFAULT = false;
|
|
|
131
131
|
/** Whether unknown properties in templates should throw by default. */
|
|
132
132
|
const THROW_ON_UNKNOWN_PROPERTIES_DEFAULT = false;
|
|
133
133
|
/** Whether defer blocks should use manual triggering or play through normally. */
|
|
134
|
-
const DEFER_BLOCK_DEFAULT_BEHAVIOR =
|
|
134
|
+
const DEFER_BLOCK_DEFAULT_BEHAVIOR = _DeferBlockBehavior.Playthrough;
|
|
135
135
|
/**
|
|
136
136
|
* An abstract class for inserting the root test component element in a platform independent way.
|
|
137
137
|
*
|
|
@@ -175,12 +175,12 @@ class TestBedApplicationErrorHandler {
|
|
|
175
175
|
throw e;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
static ɵfac =
|
|
179
|
-
static ɵprov = i0.ɵɵ
|
|
178
|
+
static ɵfac = function TestBedApplicationErrorHandler_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TestBedApplicationErrorHandler)(); };
|
|
179
|
+
static ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: TestBedApplicationErrorHandler, factory: TestBedApplicationErrorHandler.ɵfac });
|
|
180
180
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TestBedApplicationErrorHandler, [{
|
|
182
|
+
type: Injectable
|
|
183
|
+
}], null, null); })();
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
186
|
* Fixture for debugging and testing a component.
|
|
@@ -214,7 +214,7 @@ class ComponentFixture {
|
|
|
214
214
|
/** @internal */
|
|
215
215
|
_noZoneOptionIsSet = inject$1(ComponentFixtureNoNgZone, { optional: true });
|
|
216
216
|
/** @internal */
|
|
217
|
-
_ngZone = this._noZoneOptionIsSet ? new
|
|
217
|
+
_ngZone = this._noZoneOptionIsSet ? new _NoopNgZone() : inject$1(NgZone);
|
|
218
218
|
// Inject ApplicationRef to ensure NgZone stableness causes after render hooks to run
|
|
219
219
|
// This will likely happen as a result of fixture.detectChanges because it calls ngZone.run
|
|
220
220
|
// This is a crazy way of doing things but hey, it's the world we live in.
|
|
@@ -224,12 +224,11 @@ class ComponentFixture {
|
|
|
224
224
|
/** @internal */
|
|
225
225
|
_appRef = inject$1(ApplicationRef);
|
|
226
226
|
_testAppRef = this._appRef;
|
|
227
|
-
pendingTasks = inject$1(
|
|
227
|
+
pendingTasks = inject$1(_PendingTasksInternal);
|
|
228
228
|
appErrorHandler = inject$1(TestBedApplicationErrorHandler);
|
|
229
|
-
zonelessEnabled = inject$1(
|
|
230
|
-
scheduler = inject$1(
|
|
231
|
-
rootEffectScheduler = inject$1(
|
|
232
|
-
microtaskEffectScheduler = inject$1(ɵMicrotaskEffectScheduler);
|
|
229
|
+
zonelessEnabled = inject$1(_ZONELESS_ENABLED);
|
|
230
|
+
scheduler = inject$1(_ChangeDetectionScheduler);
|
|
231
|
+
rootEffectScheduler = inject$1(_EffectScheduler);
|
|
233
232
|
autoDetectDefault = this.zonelessEnabled ? true : false;
|
|
234
233
|
autoDetect = inject$1(ComponentFixtureAutoDetect, { optional: true }) ?? this.autoDetectDefault;
|
|
235
234
|
subscriptions = new Subscription();
|
|
@@ -277,7 +276,6 @@ class ComponentFixture {
|
|
|
277
276
|
* Trigger a change detection cycle for the component.
|
|
278
277
|
*/
|
|
279
278
|
detectChanges(checkNoChanges = true) {
|
|
280
|
-
this.microtaskEffectScheduler.flush();
|
|
281
279
|
const originalCheckNoChanges = this.componentRef.changeDetectorRef.checkNoChanges;
|
|
282
280
|
try {
|
|
283
281
|
if (!checkNoChanges) {
|
|
@@ -308,7 +306,6 @@ class ComponentFixture {
|
|
|
308
306
|
finally {
|
|
309
307
|
this.componentRef.changeDetectorRef.checkNoChanges = originalCheckNoChanges;
|
|
310
308
|
}
|
|
311
|
-
this.microtaskEffectScheduler.flush();
|
|
312
309
|
}
|
|
313
310
|
/**
|
|
314
311
|
* Do a change detection run to make sure there were no changes.
|
|
@@ -369,7 +366,7 @@ class ComponentFixture {
|
|
|
369
366
|
getDeferBlocks() {
|
|
370
367
|
const deferBlocks = [];
|
|
371
368
|
const lView = this.componentRef.hostView['_lView'];
|
|
372
|
-
|
|
369
|
+
_getDeferBlocks(lView, deferBlocks);
|
|
373
370
|
const deferBlockFixtures = [];
|
|
374
371
|
for (const block of deferBlocks) {
|
|
375
372
|
deferBlockFixtures.push(new DeferBlockFixture(block, this));
|
|
@@ -582,7 +579,7 @@ class MetadataOverrider {
|
|
|
582
579
|
}
|
|
583
580
|
if (override.set) {
|
|
584
581
|
if (override.remove || override.add) {
|
|
585
|
-
throw new Error(`Cannot set and add/remove ${
|
|
582
|
+
throw new Error(`Cannot set and add/remove ${_stringify(metadataClass)} at the same time!`);
|
|
586
583
|
}
|
|
587
584
|
setMetadata(props, override.set);
|
|
588
585
|
}
|
|
@@ -661,7 +658,7 @@ function _propHashKey(propName, propValue, references) {
|
|
|
661
658
|
function _serializeReference(ref, references) {
|
|
662
659
|
let id = references.get(ref);
|
|
663
660
|
if (!id) {
|
|
664
|
-
id = `${
|
|
661
|
+
id = `${_stringify(ref)}${_nextReferenceId++}`;
|
|
665
662
|
references.set(ref, id);
|
|
666
663
|
}
|
|
667
664
|
return id;
|
|
@@ -687,7 +684,7 @@ function _valueProps(obj) {
|
|
|
687
684
|
return props;
|
|
688
685
|
}
|
|
689
686
|
|
|
690
|
-
const reflection = new
|
|
687
|
+
const reflection = new _ReflectionCapabilities();
|
|
691
688
|
/**
|
|
692
689
|
* Allows to override ivy metadata for tests (via the `TestBed`).
|
|
693
690
|
*/
|
|
@@ -774,10 +771,10 @@ function isTestingModuleOverride(value) {
|
|
|
774
771
|
}
|
|
775
772
|
function assertNoStandaloneComponents(types, resolver, location) {
|
|
776
773
|
types.forEach((type) => {
|
|
777
|
-
if (
|
|
774
|
+
if (!_getAsyncClassMetadataFn(type)) {
|
|
778
775
|
const component = resolver.resolve(type);
|
|
779
776
|
if (component && (component.standalone == null || component.standalone)) {
|
|
780
|
-
throw new Error(
|
|
777
|
+
throw new Error(_generateStandaloneInDeclarationsError(type, location));
|
|
781
778
|
}
|
|
782
779
|
}
|
|
783
780
|
});
|
|
@@ -872,8 +869,8 @@ class TestBedCompiler {
|
|
|
872
869
|
moduleDef.rethrowApplicationErrors ?? RETHROW_APPLICATION_ERRORS_DEFAULT;
|
|
873
870
|
}
|
|
874
871
|
overrideModule(ngModule, override) {
|
|
875
|
-
if (
|
|
876
|
-
|
|
872
|
+
if (_USE_RUNTIME_DEPS_TRACKER_FOR_JIT) {
|
|
873
|
+
_depsTracker.clearScopeCacheFor(ngModule);
|
|
877
874
|
}
|
|
878
875
|
this.overriddenModules.add(ngModule);
|
|
879
876
|
// Compile the module right away.
|
|
@@ -930,7 +927,7 @@ class TestBedCompiler {
|
|
|
930
927
|
else {
|
|
931
928
|
providerDef = { provide: token };
|
|
932
929
|
}
|
|
933
|
-
const injectableDef = typeof token !== 'string' ?
|
|
930
|
+
const injectableDef = typeof token !== 'string' ? _getInjectableDef(token) : null;
|
|
934
931
|
const providedIn = injectableDef === null ? null : resolveForwardRef(injectableDef.providedIn);
|
|
935
932
|
const overridesBucket = providedIn === 'root' ? this.rootProviderOverrides : this.providerOverrides;
|
|
936
933
|
overridesBucket.push(providerDef);
|
|
@@ -947,12 +944,12 @@ class TestBedCompiler {
|
|
|
947
944
|
}
|
|
948
945
|
}
|
|
949
946
|
overrideTemplateUsingTestingModule(type, template) {
|
|
950
|
-
const def = type[
|
|
947
|
+
const def = type[_NG_COMP_DEF];
|
|
951
948
|
const hasStyleUrls = () => {
|
|
952
949
|
const metadata = this.resolvers.component.resolve(type);
|
|
953
950
|
return !!metadata.styleUrl || !!metadata.styleUrls?.length;
|
|
954
951
|
};
|
|
955
|
-
const overrideStyleUrls = !!def &&
|
|
952
|
+
const overrideStyleUrls = !!def && !_isComponentDefPendingResolution(type) && hasStyleUrls();
|
|
956
953
|
// In Ivy, compiling a component does not require knowing the module providing the
|
|
957
954
|
// component's scope, so overrideTemplateUsingTestingModule can be implemented purely via
|
|
958
955
|
// overrideComponent. Important: overriding template requires full Component re-compilation,
|
|
@@ -975,7 +972,7 @@ class TestBedCompiler {
|
|
|
975
972
|
return;
|
|
976
973
|
const promises = [];
|
|
977
974
|
for (const component of this.componentsWithAsyncMetadata) {
|
|
978
|
-
const asyncMetadataFn =
|
|
975
|
+
const asyncMetadataFn = _getAsyncClassMetadataFn(component);
|
|
979
976
|
if (asyncMetadataFn) {
|
|
980
977
|
promises.push(asyncMetadataFn());
|
|
981
978
|
}
|
|
@@ -1012,7 +1009,7 @@ class TestBedCompiler {
|
|
|
1012
1009
|
}
|
|
1013
1010
|
return Promise.resolve(resourceLoader.get(url));
|
|
1014
1011
|
};
|
|
1015
|
-
await
|
|
1012
|
+
await _resolveComponentResources(resolver);
|
|
1016
1013
|
}
|
|
1017
1014
|
}
|
|
1018
1015
|
finalize() {
|
|
@@ -1029,15 +1026,15 @@ class TestBedCompiler {
|
|
|
1029
1026
|
// every component.
|
|
1030
1027
|
this.componentToModuleScope.clear();
|
|
1031
1028
|
const parentInjector = this.platform.injector;
|
|
1032
|
-
this.testModuleRef = new
|
|
1029
|
+
this.testModuleRef = new _Render3NgModuleRef(this.testModuleType, parentInjector, []);
|
|
1033
1030
|
// ApplicationInitStatus.runInitializers() is marked @internal to core.
|
|
1034
1031
|
// Cast it to any before accessing it.
|
|
1035
1032
|
this.testModuleRef.injector.get(ApplicationInitStatus).runInitializers();
|
|
1036
1033
|
// Set locale ID after running app initializers, since locale information might be updated while
|
|
1037
1034
|
// running initializers. This is also consistent with the execution order while bootstrapping an
|
|
1038
1035
|
// app (see `packages/core/src/application_ref.ts` file).
|
|
1039
|
-
const localeId = this.testModuleRef.injector.get(LOCALE_ID,
|
|
1040
|
-
|
|
1036
|
+
const localeId = this.testModuleRef.injector.get(LOCALE_ID, _DEFAULT_LOCALE_ID);
|
|
1037
|
+
_setLocaleId(localeId);
|
|
1041
1038
|
return this.testModuleRef;
|
|
1042
1039
|
}
|
|
1043
1040
|
/**
|
|
@@ -1072,7 +1069,7 @@ class TestBedCompiler {
|
|
|
1072
1069
|
_getComponentFactories(moduleType) {
|
|
1073
1070
|
return maybeUnwrapFn(moduleType.ɵmod.declarations).reduce((factories, declaration) => {
|
|
1074
1071
|
const componentDef = declaration.ɵcmp;
|
|
1075
|
-
componentDef && factories.push(new
|
|
1072
|
+
componentDef && factories.push(new _Render3ComponentFactory(componentDef, this.testModuleRef));
|
|
1076
1073
|
return factories;
|
|
1077
1074
|
}, []);
|
|
1078
1075
|
}
|
|
@@ -1080,20 +1077,20 @@ class TestBedCompiler {
|
|
|
1080
1077
|
// Compile all queued components, directives, pipes.
|
|
1081
1078
|
let needsAsyncResources = false;
|
|
1082
1079
|
this.pendingComponents.forEach((declaration) => {
|
|
1083
|
-
if (
|
|
1080
|
+
if (_getAsyncClassMetadataFn(declaration)) {
|
|
1084
1081
|
throw new Error(`Component '${declaration.name}' has unresolved metadata. ` +
|
|
1085
1082
|
`Please call \`await TestBed.compileComponents()\` before running this test.`);
|
|
1086
1083
|
}
|
|
1087
|
-
needsAsyncResources = needsAsyncResources ||
|
|
1084
|
+
needsAsyncResources = needsAsyncResources || _isComponentDefPendingResolution(declaration);
|
|
1088
1085
|
const metadata = this.resolvers.component.resolve(declaration);
|
|
1089
1086
|
if (metadata === null) {
|
|
1090
1087
|
throw invalidTypeError(declaration.name, 'Component');
|
|
1091
1088
|
}
|
|
1092
|
-
this.maybeStoreNgDef(
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1089
|
+
this.maybeStoreNgDef(_NG_COMP_DEF, declaration);
|
|
1090
|
+
if (_USE_RUNTIME_DEPS_TRACKER_FOR_JIT) {
|
|
1091
|
+
_depsTracker.clearScopeCacheFor(declaration);
|
|
1095
1092
|
}
|
|
1096
|
-
|
|
1093
|
+
_compileComponent(declaration, metadata);
|
|
1097
1094
|
});
|
|
1098
1095
|
this.pendingComponents.clear();
|
|
1099
1096
|
this.pendingDirectives.forEach((declaration) => {
|
|
@@ -1101,8 +1098,8 @@ class TestBedCompiler {
|
|
|
1101
1098
|
if (metadata === null) {
|
|
1102
1099
|
throw invalidTypeError(declaration.name, 'Directive');
|
|
1103
1100
|
}
|
|
1104
|
-
this.maybeStoreNgDef(
|
|
1105
|
-
|
|
1101
|
+
this.maybeStoreNgDef(_NG_DIR_DEF, declaration);
|
|
1102
|
+
_compileDirective(declaration, metadata);
|
|
1106
1103
|
});
|
|
1107
1104
|
this.pendingDirectives.clear();
|
|
1108
1105
|
this.pendingPipes.forEach((declaration) => {
|
|
@@ -1110,8 +1107,8 @@ class TestBedCompiler {
|
|
|
1110
1107
|
if (metadata === null) {
|
|
1111
1108
|
throw invalidTypeError(declaration.name, 'Pipe');
|
|
1112
1109
|
}
|
|
1113
|
-
this.maybeStoreNgDef(
|
|
1114
|
-
|
|
1110
|
+
this.maybeStoreNgDef(_NG_PIPE_DEF, declaration);
|
|
1111
|
+
_compilePipe(declaration, metadata);
|
|
1115
1112
|
});
|
|
1116
1113
|
this.pendingPipes.clear();
|
|
1117
1114
|
return needsAsyncResources;
|
|
@@ -1121,16 +1118,16 @@ class TestBedCompiler {
|
|
|
1121
1118
|
// Module overrides (via `TestBed.overrideModule`) might affect scopes that were previously
|
|
1122
1119
|
// calculated and stored in `transitiveCompileScopes`. If module overrides are present,
|
|
1123
1120
|
// collect all affected modules and reset scopes to force their re-calculation.
|
|
1124
|
-
const testingModuleDef = this.testModuleType[
|
|
1121
|
+
const testingModuleDef = this.testModuleType[_NG_MOD_DEF];
|
|
1125
1122
|
const affectedModules = this.collectModulesAffectedByOverrides(testingModuleDef.imports);
|
|
1126
1123
|
if (affectedModules.size > 0) {
|
|
1127
1124
|
affectedModules.forEach((moduleType) => {
|
|
1128
|
-
if (
|
|
1129
|
-
this.storeFieldOfDefOnType(moduleType,
|
|
1130
|
-
moduleType[
|
|
1125
|
+
if (!_USE_RUNTIME_DEPS_TRACKER_FOR_JIT) {
|
|
1126
|
+
this.storeFieldOfDefOnType(moduleType, _NG_MOD_DEF, 'transitiveCompileScopes');
|
|
1127
|
+
moduleType[_NG_MOD_DEF].transitiveCompileScopes = null;
|
|
1131
1128
|
}
|
|
1132
1129
|
else {
|
|
1133
|
-
|
|
1130
|
+
_depsTracker.clearScopeCacheFor(moduleType);
|
|
1134
1131
|
}
|
|
1135
1132
|
});
|
|
1136
1133
|
}
|
|
@@ -1140,16 +1137,16 @@ class TestBedCompiler {
|
|
|
1140
1137
|
if (!moduleToScope.has(moduleType)) {
|
|
1141
1138
|
const isTestingModule = isTestingModuleOverride(moduleType);
|
|
1142
1139
|
const realType = isTestingModule ? this.testModuleType : moduleType;
|
|
1143
|
-
moduleToScope.set(moduleType,
|
|
1140
|
+
moduleToScope.set(moduleType, _transitiveScopesFor(realType));
|
|
1144
1141
|
}
|
|
1145
1142
|
return moduleToScope.get(moduleType);
|
|
1146
1143
|
};
|
|
1147
1144
|
this.componentToModuleScope.forEach((moduleType, componentType) => {
|
|
1148
1145
|
if (moduleType !== null) {
|
|
1149
1146
|
const moduleScope = getScopeOfModule(moduleType);
|
|
1150
|
-
this.storeFieldOfDefOnType(componentType,
|
|
1151
|
-
this.storeFieldOfDefOnType(componentType,
|
|
1152
|
-
|
|
1147
|
+
this.storeFieldOfDefOnType(componentType, _NG_COMP_DEF, 'directiveDefs');
|
|
1148
|
+
this.storeFieldOfDefOnType(componentType, _NG_COMP_DEF, 'pipeDefs');
|
|
1149
|
+
_patchComponentDefWithScope(getComponentDef(componentType), moduleScope);
|
|
1153
1150
|
}
|
|
1154
1151
|
// `tView` that is stored on component def contains information about directives and pipes
|
|
1155
1152
|
// that are in the scope of this component. Patching component scope will cause `tView` to be
|
|
@@ -1158,20 +1155,20 @@ class TestBedCompiler {
|
|
|
1158
1155
|
// Resetting `tView` is also needed for cases when we apply provider overrides and those
|
|
1159
1156
|
// providers are defined on component's level, in which case they may end up included into
|
|
1160
1157
|
// `tView.blueprint`.
|
|
1161
|
-
this.storeFieldOfDefOnType(componentType,
|
|
1158
|
+
this.storeFieldOfDefOnType(componentType, _NG_COMP_DEF, 'tView');
|
|
1162
1159
|
});
|
|
1163
1160
|
this.componentToModuleScope.clear();
|
|
1164
1161
|
}
|
|
1165
1162
|
applyProviderOverrides() {
|
|
1166
1163
|
const maybeApplyOverrides = (field) => (type) => {
|
|
1167
|
-
const resolver = field ===
|
|
1164
|
+
const resolver = field === _NG_COMP_DEF ? this.resolvers.component : this.resolvers.directive;
|
|
1168
1165
|
const metadata = resolver.resolve(type);
|
|
1169
1166
|
if (this.hasProviderOverrides(metadata.providers)) {
|
|
1170
1167
|
this.patchDefWithProviderOverrides(type, field);
|
|
1171
1168
|
}
|
|
1172
1169
|
};
|
|
1173
|
-
this.seenComponents.forEach(maybeApplyOverrides(
|
|
1174
|
-
this.seenDirectives.forEach(maybeApplyOverrides(
|
|
1170
|
+
this.seenComponents.forEach(maybeApplyOverrides(_NG_COMP_DEF));
|
|
1171
|
+
this.seenDirectives.forEach(maybeApplyOverrides(_NG_DIR_DEF));
|
|
1175
1172
|
this.seenComponents.clear();
|
|
1176
1173
|
this.seenDirectives.clear();
|
|
1177
1174
|
}
|
|
@@ -1194,7 +1191,7 @@ class TestBedCompiler {
|
|
|
1194
1191
|
// detailed error messages. The fact that the code relies on this line being
|
|
1195
1192
|
// present here is suspicious and should be refactored in a way that the line
|
|
1196
1193
|
// below can be moved (for ex. after an early exit check below).
|
|
1197
|
-
const injectorDef = type[
|
|
1194
|
+
const injectorDef = type[_NG_INJ_DEF];
|
|
1198
1195
|
// No provider overrides, exit early.
|
|
1199
1196
|
if (this.providerOverridesByToken.size === 0)
|
|
1200
1197
|
return;
|
|
@@ -1212,12 +1209,12 @@ class TestBedCompiler {
|
|
|
1212
1209
|
...(this.providerOverridesByModule.get(type) || []),
|
|
1213
1210
|
];
|
|
1214
1211
|
if (this.hasProviderOverrides(providers)) {
|
|
1215
|
-
this.maybeStoreNgDef(
|
|
1216
|
-
this.storeFieldOfDefOnType(type,
|
|
1212
|
+
this.maybeStoreNgDef(_NG_INJ_DEF, type);
|
|
1213
|
+
this.storeFieldOfDefOnType(type, _NG_INJ_DEF, 'providers');
|
|
1217
1214
|
injectorDef.providers = this.getOverriddenProviders(providers);
|
|
1218
1215
|
}
|
|
1219
1216
|
// Apply provider overrides to imported modules recursively
|
|
1220
|
-
const moduleDef = type[
|
|
1217
|
+
const moduleDef = type[_NG_MOD_DEF];
|
|
1221
1218
|
const imports = maybeUnwrapFn(moduleDef.imports);
|
|
1222
1219
|
for (const importedModule of imports) {
|
|
1223
1220
|
this.applyProviderOverridesInScope(importedModule);
|
|
@@ -1237,7 +1234,7 @@ class TestBedCompiler {
|
|
|
1237
1234
|
}
|
|
1238
1235
|
}
|
|
1239
1236
|
patchComponentsWithExistingStyles() {
|
|
1240
|
-
this.existingComponentStyles.forEach((styles, type) => (type[
|
|
1237
|
+
this.existingComponentStyles.forEach((styles, type) => (type[_NG_COMP_DEF].styles = styles));
|
|
1241
1238
|
this.existingComponentStyles.clear();
|
|
1242
1239
|
}
|
|
1243
1240
|
queueTypeArray(arr, moduleType) {
|
|
@@ -1252,12 +1249,12 @@ class TestBedCompiler {
|
|
|
1252
1249
|
}
|
|
1253
1250
|
recompileNgModule(ngModule, metadata) {
|
|
1254
1251
|
// Cache the initial ngModuleDef as it will be overwritten.
|
|
1255
|
-
this.maybeStoreNgDef(
|
|
1256
|
-
this.maybeStoreNgDef(
|
|
1257
|
-
|
|
1252
|
+
this.maybeStoreNgDef(_NG_MOD_DEF, ngModule);
|
|
1253
|
+
this.maybeStoreNgDef(_NG_INJ_DEF, ngModule);
|
|
1254
|
+
_compileNgModuleDefs(ngModule, metadata);
|
|
1258
1255
|
}
|
|
1259
1256
|
maybeRegisterComponentWithAsyncMetadata(type) {
|
|
1260
|
-
const asyncMetadataFn =
|
|
1257
|
+
const asyncMetadataFn = _getAsyncClassMetadataFn(type);
|
|
1261
1258
|
if (asyncMetadataFn) {
|
|
1262
1259
|
this.componentsWithAsyncMetadata.add(type);
|
|
1263
1260
|
}
|
|
@@ -1271,7 +1268,7 @@ class TestBedCompiler {
|
|
|
1271
1268
|
// Check whether a give Type has respective NG def (ɵcmp) and compile if def is
|
|
1272
1269
|
// missing. That might happen in case a class without any Angular decorators extends another
|
|
1273
1270
|
// class where Component/Directive/Pipe decorator is defined.
|
|
1274
|
-
if (
|
|
1271
|
+
if (_isComponentDefPendingResolution(type) || !type.hasOwnProperty(_NG_COMP_DEF)) {
|
|
1275
1272
|
this.pendingComponents.add(type);
|
|
1276
1273
|
}
|
|
1277
1274
|
this.seenComponents.add(type);
|
|
@@ -1298,14 +1295,14 @@ class TestBedCompiler {
|
|
|
1298
1295
|
}
|
|
1299
1296
|
const directive = this.resolvers.directive.resolve(type);
|
|
1300
1297
|
if (directive) {
|
|
1301
|
-
if (!type.hasOwnProperty(
|
|
1298
|
+
if (!type.hasOwnProperty(_NG_DIR_DEF)) {
|
|
1302
1299
|
this.pendingDirectives.add(type);
|
|
1303
1300
|
}
|
|
1304
1301
|
this.seenDirectives.add(type);
|
|
1305
1302
|
return;
|
|
1306
1303
|
}
|
|
1307
1304
|
const pipe = this.resolvers.pipe.resolve(type);
|
|
1308
|
-
if (pipe && !type.hasOwnProperty(
|
|
1305
|
+
if (pipe && !type.hasOwnProperty(_NG_PIPE_DEF)) {
|
|
1309
1306
|
this.pendingPipes.add(type);
|
|
1310
1307
|
return;
|
|
1311
1308
|
}
|
|
@@ -1393,7 +1390,7 @@ class TestBedCompiler {
|
|
|
1393
1390
|
path.forEach((item) => affectedModules.add(item));
|
|
1394
1391
|
}
|
|
1395
1392
|
// Examine module imports recursively to look for overridden modules.
|
|
1396
|
-
const moduleDef = value[
|
|
1393
|
+
const moduleDef = value[_NG_MOD_DEF];
|
|
1397
1394
|
calcAffectedModulesRecur(maybeUnwrapFn(moduleDef.imports), path.concat(value));
|
|
1398
1395
|
}
|
|
1399
1396
|
}
|
|
@@ -1431,7 +1428,7 @@ class TestBedCompiler {
|
|
|
1431
1428
|
if (this.originalComponentResolutionQueue === null) {
|
|
1432
1429
|
this.originalComponentResolutionQueue = new Map();
|
|
1433
1430
|
}
|
|
1434
|
-
|
|
1431
|
+
_clearResolutionOfComponentResourcesQueue().forEach((value, key) => this.originalComponentResolutionQueue.set(key, value));
|
|
1435
1432
|
}
|
|
1436
1433
|
/*
|
|
1437
1434
|
* Restores component resolution queue to the previously saved state. This operation is performed
|
|
@@ -1440,7 +1437,7 @@ class TestBedCompiler {
|
|
|
1440
1437
|
*/
|
|
1441
1438
|
restoreComponentResolutionQueue() {
|
|
1442
1439
|
if (this.originalComponentResolutionQueue !== null) {
|
|
1443
|
-
|
|
1440
|
+
_restoreComponentResolutionQueue(this.originalComponentResolutionQueue);
|
|
1444
1441
|
this.originalComponentResolutionQueue = null;
|
|
1445
1442
|
}
|
|
1446
1443
|
}
|
|
@@ -1452,8 +1449,8 @@ class TestBedCompiler {
|
|
|
1452
1449
|
});
|
|
1453
1450
|
// Restore initial component/directive/pipe defs
|
|
1454
1451
|
this.initialNgDefs.forEach((defs, type) => {
|
|
1455
|
-
if (
|
|
1456
|
-
|
|
1452
|
+
if (_USE_RUNTIME_DEPS_TRACKER_FOR_JIT) {
|
|
1453
|
+
_depsTracker.clearScopeCacheFor(type);
|
|
1457
1454
|
}
|
|
1458
1455
|
defs.forEach((descriptor, prop) => {
|
|
1459
1456
|
if (!descriptor) {
|
|
@@ -1474,24 +1471,24 @@ class TestBedCompiler {
|
|
|
1474
1471
|
this.scopesWithOverriddenProviders.clear();
|
|
1475
1472
|
this.restoreComponentResolutionQueue();
|
|
1476
1473
|
// Restore the locale ID to the default value, this shouldn't be necessary but we never know
|
|
1477
|
-
|
|
1474
|
+
_setLocaleId(_DEFAULT_LOCALE_ID);
|
|
1478
1475
|
}
|
|
1479
1476
|
compileTestModule() {
|
|
1480
1477
|
class RootScopeModule {
|
|
1481
1478
|
}
|
|
1482
|
-
|
|
1479
|
+
_compileNgModuleDefs(RootScopeModule, {
|
|
1483
1480
|
providers: [
|
|
1484
1481
|
...this.rootProviderOverrides,
|
|
1485
|
-
|
|
1482
|
+
_internalProvideZoneChangeDetection({}),
|
|
1486
1483
|
TestBedApplicationErrorHandler,
|
|
1487
|
-
{ provide:
|
|
1484
|
+
{ provide: _ChangeDetectionScheduler, useExisting: _ChangeDetectionSchedulerImpl },
|
|
1488
1485
|
],
|
|
1489
1486
|
});
|
|
1490
1487
|
const providers = [
|
|
1491
1488
|
{ provide: Compiler, useFactory: () => new R3TestCompiler(this) },
|
|
1492
|
-
{ provide:
|
|
1489
|
+
{ provide: _DEFER_BLOCK_CONFIG, useValue: { behavior: this.deferBlockBehavior } },
|
|
1493
1490
|
{
|
|
1494
|
-
provide:
|
|
1491
|
+
provide: _INTERNAL_APPLICATION_ERROR_HANDLER,
|
|
1495
1492
|
useFactory: () => {
|
|
1496
1493
|
if (this.rethrowApplicationTickErrors) {
|
|
1497
1494
|
const handler = inject$1(TestBedApplicationErrorHandler);
|
|
@@ -1510,7 +1507,7 @@ class TestBedCompiler {
|
|
|
1510
1507
|
...this.providerOverrides,
|
|
1511
1508
|
];
|
|
1512
1509
|
const imports = [RootScopeModule, this.additionalModuleTypes, this.imports || []];
|
|
1513
|
-
|
|
1510
|
+
_compileNgModuleDefs(this.testModuleType, {
|
|
1514
1511
|
declarations: this.declarations,
|
|
1515
1512
|
imports,
|
|
1516
1513
|
schemas: this.schemas,
|
|
@@ -1524,7 +1521,7 @@ class TestBedCompiler {
|
|
|
1524
1521
|
return this._injector;
|
|
1525
1522
|
}
|
|
1526
1523
|
const providers = [];
|
|
1527
|
-
const compilerOptions = this.platform.injector.get(COMPILER_OPTIONS);
|
|
1524
|
+
const compilerOptions = this.platform.injector.get(COMPILER_OPTIONS, []);
|
|
1528
1525
|
compilerOptions.forEach((opts) => {
|
|
1529
1526
|
if (opts.providers) {
|
|
1530
1527
|
providers.push(opts.providers);
|
|
@@ -1636,7 +1633,7 @@ function identityFn(value) {
|
|
|
1636
1633
|
function flattenProviders(providers, mapFn = identityFn) {
|
|
1637
1634
|
const out = [];
|
|
1638
1635
|
for (let provider of providers) {
|
|
1639
|
-
if (
|
|
1636
|
+
if (_isEnvironmentProviders(provider)) {
|
|
1640
1637
|
provider = provider.ɵproviders;
|
|
1641
1638
|
}
|
|
1642
1639
|
if (Array.isArray(provider)) {
|
|
@@ -1672,11 +1669,11 @@ class R3TestCompiler {
|
|
|
1672
1669
|
}
|
|
1673
1670
|
compileModuleSync(moduleType) {
|
|
1674
1671
|
this.testBed._compileNgModuleSync(moduleType);
|
|
1675
|
-
return new
|
|
1672
|
+
return new _NgModuleFactory(moduleType);
|
|
1676
1673
|
}
|
|
1677
1674
|
async compileModuleAsync(moduleType) {
|
|
1678
1675
|
await this.testBed._compileNgModuleAsync(moduleType);
|
|
1679
|
-
return new
|
|
1676
|
+
return new _NgModuleFactory(moduleType);
|
|
1680
1677
|
}
|
|
1681
1678
|
compileModuleAndAllComponentsSync(moduleType) {
|
|
1682
1679
|
const ngModuleFactory = this.compileModuleSync(moduleType);
|
|
@@ -1697,6 +1694,8 @@ class R3TestCompiler {
|
|
|
1697
1694
|
}
|
|
1698
1695
|
|
|
1699
1696
|
// The formatter and CI disagree on how this import statement should be formatted. Both try to keep
|
|
1697
|
+
// it on one line, too, which has gotten very hard to read & manage. So disable the formatter for
|
|
1698
|
+
// this statement only.
|
|
1700
1699
|
let _nextRootElementId = 0;
|
|
1701
1700
|
/**
|
|
1702
1701
|
* Returns a singleton of the `TestBed` class.
|
|
@@ -1834,12 +1833,8 @@ class TestBedImpl {
|
|
|
1834
1833
|
static overrideProvider(token, provider) {
|
|
1835
1834
|
return TestBedImpl.INSTANCE.overrideProvider(token, provider);
|
|
1836
1835
|
}
|
|
1837
|
-
static inject(token, notFoundValue,
|
|
1838
|
-
return TestBedImpl.INSTANCE.inject(token, notFoundValue,
|
|
1839
|
-
}
|
|
1840
|
-
/** @deprecated from v9.0.0 use TestBed.inject */
|
|
1841
|
-
static get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
|
|
1842
|
-
return TestBedImpl.INSTANCE.inject(token, notFoundValue, flags);
|
|
1836
|
+
static inject(token, notFoundValue, options) {
|
|
1837
|
+
return TestBedImpl.INSTANCE.inject(token, notFoundValue, options);
|
|
1843
1838
|
}
|
|
1844
1839
|
/**
|
|
1845
1840
|
* Runs the given function in the `EnvironmentInjector` context of `TestBed`.
|
|
@@ -1906,7 +1901,7 @@ class TestBedImpl {
|
|
|
1906
1901
|
// used to track the state of the NgModule registry and reset it correctly. Instead, when we
|
|
1907
1902
|
// know we're in a testing scenario, we disable the check for duplicate NgModule registration
|
|
1908
1903
|
// completely.
|
|
1909
|
-
|
|
1904
|
+
_setAllowDuplicateNgModuleIdsForTest(true);
|
|
1910
1905
|
}
|
|
1911
1906
|
/**
|
|
1912
1907
|
* Reset the providers for the test injector.
|
|
@@ -1919,19 +1914,19 @@ class TestBedImpl {
|
|
|
1919
1914
|
this.platform = null;
|
|
1920
1915
|
this.ngModule = null;
|
|
1921
1916
|
TestBedImpl._environmentTeardownOptions = undefined;
|
|
1922
|
-
|
|
1917
|
+
_setAllowDuplicateNgModuleIdsForTest(false);
|
|
1923
1918
|
}
|
|
1924
1919
|
resetTestingModule() {
|
|
1925
1920
|
this.checkGlobalCompilationFinished();
|
|
1926
|
-
|
|
1921
|
+
_resetCompiledComponents();
|
|
1927
1922
|
if (this._compiler !== null) {
|
|
1928
1923
|
this.compiler.restoreOriginalState();
|
|
1929
1924
|
}
|
|
1930
1925
|
this._compiler = new TestBedCompiler(this.platform, this.ngModule);
|
|
1931
1926
|
// Restore the previous value of the "error on unknown elements" option
|
|
1932
|
-
|
|
1927
|
+
_setUnknownElementStrictMode(this._previousErrorOnUnknownElementsOption ?? THROW_ON_UNKNOWN_ELEMENTS_DEFAULT);
|
|
1933
1928
|
// Restore the previous value of the "error on unknown properties" option
|
|
1934
|
-
|
|
1929
|
+
_setUnknownPropertyStrictMode(this._previousErrorOnUnknownPropertiesOption ?? THROW_ON_UNKNOWN_PROPERTIES_DEFAULT);
|
|
1935
1930
|
// We have to chain a couple of try/finally blocks, because each step can
|
|
1936
1931
|
// throw errors and we don't want it to interrupt the next step and we also
|
|
1937
1932
|
// want an error to be thrown at the end.
|
|
@@ -1978,30 +1973,26 @@ class TestBedImpl {
|
|
|
1978
1973
|
this._instanceDeferBlockBehavior = moduleDef.deferBlockBehavior ?? DEFER_BLOCK_DEFAULT_BEHAVIOR;
|
|
1979
1974
|
// Store the current value of the strict mode option,
|
|
1980
1975
|
// so we can restore it later
|
|
1981
|
-
this._previousErrorOnUnknownElementsOption =
|
|
1982
|
-
|
|
1983
|
-
this._previousErrorOnUnknownPropertiesOption =
|
|
1984
|
-
|
|
1976
|
+
this._previousErrorOnUnknownElementsOption = _getUnknownElementStrictMode();
|
|
1977
|
+
_setUnknownElementStrictMode(this.shouldThrowErrorOnUnknownElements());
|
|
1978
|
+
this._previousErrorOnUnknownPropertiesOption = _getUnknownPropertyStrictMode();
|
|
1979
|
+
_setUnknownPropertyStrictMode(this.shouldThrowErrorOnUnknownProperties());
|
|
1985
1980
|
this.compiler.configureTestingModule(moduleDef);
|
|
1986
1981
|
return this;
|
|
1987
1982
|
}
|
|
1988
1983
|
compileComponents() {
|
|
1989
1984
|
return this.compiler.compileComponents();
|
|
1990
1985
|
}
|
|
1991
|
-
inject(token, notFoundValue,
|
|
1986
|
+
inject(token, notFoundValue, options) {
|
|
1992
1987
|
if (token === TestBed) {
|
|
1993
1988
|
return this;
|
|
1994
1989
|
}
|
|
1995
1990
|
const UNDEFINED = {};
|
|
1996
|
-
const result = this.testModuleRef.injector.get(token, UNDEFINED,
|
|
1991
|
+
const result = this.testModuleRef.injector.get(token, UNDEFINED, options);
|
|
1997
1992
|
return result === UNDEFINED
|
|
1998
|
-
? this.compiler.injector.get(token, notFoundValue,
|
|
1993
|
+
? this.compiler.injector.get(token, notFoundValue, options)
|
|
1999
1994
|
: result;
|
|
2000
1995
|
}
|
|
2001
|
-
/** @deprecated from v9.0.0 use TestBed.inject */
|
|
2002
|
-
get(token, notFoundValue = Injector.THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
|
|
2003
|
-
return this.inject(token, notFoundValue, flags);
|
|
2004
|
-
}
|
|
2005
1996
|
runInInjectionContext(fn) {
|
|
2006
1997
|
return runInInjectionContext(this.inject(EnvironmentInjector), fn);
|
|
2007
1998
|
}
|
|
@@ -2049,15 +2040,15 @@ class TestBedImpl {
|
|
|
2049
2040
|
const testComponentRenderer = this.inject(TestComponentRenderer);
|
|
2050
2041
|
const rootElId = `root${_nextRootElementId++}`;
|
|
2051
2042
|
testComponentRenderer.insertRootElement(rootElId);
|
|
2052
|
-
if (
|
|
2043
|
+
if (_getAsyncClassMetadataFn(type)) {
|
|
2053
2044
|
throw new Error(`Component '${type.name}' has unresolved metadata. ` +
|
|
2054
2045
|
`Please call \`await TestBed.compileComponents()\` before running this test.`);
|
|
2055
2046
|
}
|
|
2056
2047
|
const componentDef = type.ɵcmp;
|
|
2057
2048
|
if (!componentDef) {
|
|
2058
|
-
throw new Error(`It looks like '${
|
|
2049
|
+
throw new Error(`It looks like '${_stringify(type)}' has not been compiled.`);
|
|
2059
2050
|
}
|
|
2060
|
-
const componentFactory = new
|
|
2051
|
+
const componentFactory = new _Render3ComponentFactory(componentDef);
|
|
2061
2052
|
const initComponent = () => {
|
|
2062
2053
|
const componentRef = componentFactory.create(Injector.NULL, [], `#${rootElId}`, this.testModuleRef);
|
|
2063
2054
|
return this.runInInjectionContext(() => new ComponentFixture(componentRef));
|
|
@@ -2110,7 +2101,7 @@ class TestBedImpl {
|
|
|
2110
2101
|
// Checking _testNgModuleRef is null should not be necessary, but is left in as an additional
|
|
2111
2102
|
// guard that compilations queued in tests (after instantiation) are never flushed accidentally.
|
|
2112
2103
|
if (!this.globalCompilationChecked && this._testModuleRef === null) {
|
|
2113
|
-
|
|
2104
|
+
_flushModuleScopingQueueAsMuchAsPossible();
|
|
2114
2105
|
}
|
|
2115
2106
|
this.globalCompilationChecked = true;
|
|
2116
2107
|
}
|
|
@@ -2198,8 +2189,7 @@ class TestBedImpl {
|
|
|
2198
2189
|
* @developerPreview
|
|
2199
2190
|
*/
|
|
2200
2191
|
flushEffects() {
|
|
2201
|
-
this.inject(
|
|
2202
|
-
this.inject(ɵEffectScheduler).flush();
|
|
2192
|
+
this.inject(_EffectScheduler).flush();
|
|
2203
2193
|
}
|
|
2204
2194
|
}
|
|
2205
2195
|
/**
|
|
@@ -2313,12 +2303,6 @@ function getCleanupHook(expectedTeardownValue) {
|
|
|
2313
2303
|
// TODO(iminar): Remove this code in a safe way.
|
|
2314
2304
|
const __core_private_testing_placeholder__ = '';
|
|
2315
2305
|
|
|
2316
|
-
/**
|
|
2317
|
-
* @module
|
|
2318
|
-
* @description
|
|
2319
|
-
* Entry point for all public APIs of the core/testing package.
|
|
2320
|
-
*/
|
|
2321
|
-
|
|
2322
2306
|
/**
|
|
2323
2307
|
* Fake implementation of user agent history and navigation behavior. This is a
|
|
2324
2308
|
* high-fidelity implementation of browser behavior that attempts to emulate
|
|
@@ -2708,9 +2692,7 @@ class FakeNavigation {
|
|
|
2708
2692
|
else if (navigateEvent.navigationType === 'reload') {
|
|
2709
2693
|
this.updateNavigationEntriesForSameDocumentNavigation(navigateEvent);
|
|
2710
2694
|
}
|
|
2711
|
-
else
|
|
2712
|
-
// "If navigationType is "traverse", then this event firing is happening as part of the traversal process, and that process will take care of performing the appropriate session history entry updates."
|
|
2713
|
-
}
|
|
2695
|
+
else ;
|
|
2714
2696
|
}
|
|
2715
2697
|
/**
|
|
2716
2698
|
* Implementation for a push or replace navigation.
|
|
@@ -3171,14 +3153,5 @@ class InternalNavigationResult {
|
|
|
3171
3153
|
}
|
|
3172
3154
|
}
|
|
3173
3155
|
|
|
3174
|
-
/// <reference types="jasmine" />
|
|
3175
|
-
// This file only reexports content of the `src` folder. Keep it that way.
|
|
3176
|
-
|
|
3177
|
-
// This file is not used to build this module. It is only used during editing
|
|
3178
|
-
|
|
3179
|
-
/**
|
|
3180
|
-
* Generated bundle index. Do not edit.
|
|
3181
|
-
*/
|
|
3182
|
-
|
|
3183
3156
|
export { ComponentFixture, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, DeferBlockFixture, InjectSetupWrapper, TestBed, TestComponentRenderer, __core_private_testing_placeholder__, discardPeriodicTasks, fakeAsync, flush, flushMicrotasks, getTestBed, inject, resetFakeAsyncZone, tick, waitForAsync, withModule, FakeNavigation as ɵFakeNavigation, MetadataOverrider as ɵMetadataOverrider };
|
|
3184
3157
|
//# sourceMappingURL=testing.mjs.map
|