@angular/core 19.0.0-next.8 → 19.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/core.mjs +21591 -19590
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +71 -47
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
- package/fesm2022/primitives/signals.mjs +8 -6
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +90 -10
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +177 -114
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +591 -101
- package/package.json +1 -1
- package/primitives/event-dispatch/index.d.ts +7 -4
- package/primitives/signals/index.d.ts +7 -1
- package/rxjs-interop/index.d.ts +35 -4
- package/schematics/bundles/{checker-e68dd7ce.js → checker-2451e7c5.js} +2464 -1132
- package/schematics/bundles/{group_replacements-472b2387.js → combine_units-c52492ab.js} +1964 -2207
- package/schematics/bundles/{compiler_host-9a4d0c2b.js → compiler_host-f54f8309.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +3 -3
- package/schematics/bundles/explicit-standalone-flag.js +31 -11
- package/schematics/bundles/{imports-4ac08251.js → imports-44987700.js} +1 -1
- package/schematics/bundles/inject-migration.js +122 -48
- package/schematics/bundles/{leading_space-d190b83b.js → leading_space-6e7a8ec6.js} +1 -1
- package/schematics/bundles/migrate_ts_type_references-ab18a7c3.js +1463 -0
- package/schematics/bundles/{nodes-0e7d45ca.js → ng_decorators-3ad437d2.js} +2 -15
- package/schematics/bundles/nodes-ffdce442.js +27 -0
- package/schematics/bundles/output-migration.js +7450 -0
- package/schematics/bundles/pending-tasks.js +5 -5
- package/schematics/bundles/{program-105283c5.js → program-58424797.js} +1359 -455
- package/schematics/bundles/{project_tsconfig_paths-e9ccccbf.js → project_tsconfig_paths-6c9cde78.js} +1 -1
- package/schematics/bundles/provide-initializer.js +190 -0
- package/schematics/bundles/route-lazy-loading.js +4 -4
- package/schematics/bundles/signal-input-migration.js +197 -349
- package/schematics/bundles/signal-queries-migration.js +462 -185
- package/schematics/bundles/signals.js +54 -0
- package/schematics/bundles/standalone-migration.js +38 -20
- package/schematics/collection.json +11 -0
- package/schematics/migrations.json +7 -1
- package/schematics/ng-generate/output-migration/schema.json +19 -0
- package/schematics/ng-generate/signal-queries-migration/schema.json +11 -0
- package/schematics/ng-generate/signals/schema.json +65 -0
- package/testing/index.d.ts +3 -1
package/fesm2022/testing.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v19.0.0-
|
|
2
|
+
* @license Angular v19.0.0-rc.0
|
|
3
3
|
* (c) 2010-2024 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, ɵDeferBlockBehavior, InjectionToken, inject as inject$1, NgZone, ErrorHandler, Injectable, ɵNoopNgZone, ApplicationRef, ɵPendingTasks, ɵZONELESS_ENABLED, ɵChangeDetectionScheduler, ɵEffectScheduler, ɵMicrotaskEffectScheduler, getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetAsyncClassMetadataFn, ɵgenerateStandaloneInDeclarationsError, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵisComponentDefPendingResolution, ɵresolveComponentResources, ɵ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, ɵclearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue, ɵinternalProvideZoneChangeDetection, ɵChangeDetectionSchedulerImpl, Compiler, ɵDEFER_BLOCK_CONFIG, ɵINTERNAL_APPLICATION_ERROR_HANDLER, COMPILER_OPTIONS, Injector, ɵisEnvironmentProviders, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, InjectFlags, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, runInInjectionContext, EnvironmentInjector, ɵflushModuleScopingQueueAsMuchAsPossible } from '@angular/core';
|
|
8
|
+
import { ɵDeferBlockState, ɵtriggerResourceLoading, ɵrenderDeferBlockState, ɵCONTAINER_HEADER_OFFSET, ɵgetDeferBlocks, ɵDeferBlockBehavior, InjectionToken, inject as inject$1, NgZone, ErrorHandler, Injectable, ɵNoopNgZone, ApplicationRef, ɵPendingTasks, ɵZONELESS_ENABLED, ɵChangeDetectionScheduler, ɵEffectScheduler, ɵMicrotaskEffectScheduler, getDebugNode, RendererFactory2, ɵstringify, ɵReflectionCapabilities, Directive, Component, Pipe, NgModule, ɵgetAsyncClassMetadataFn, ɵNG_STANDALONE_DEFAULT_VALUE, ɵgenerateStandaloneInDeclarationsError, ɵUSE_RUNTIME_DEPS_TRACKER_FOR_JIT, ɵdepsTracker, ɵgetInjectableDef, resolveForwardRef, ɵNG_COMP_DEF, ɵisComponentDefPendingResolution, ɵresolveComponentResources, ɵ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, ɵclearResolutionOfComponentResourcesQueue, ɵrestoreComponentResolutionQueue, ɵinternalProvideZoneChangeDetection, ɵChangeDetectionSchedulerImpl, Compiler, ɵDEFER_BLOCK_CONFIG, ɵINTERNAL_APPLICATION_ERROR_HANDLER, COMPILER_OPTIONS, Injector, ɵisEnvironmentProviders, ɵNgModuleFactory, ModuleWithComponentFactories, ɵconvertToBitFlags, InjectFlags, ɵsetAllowDuplicateNgModuleIdsForTest, ɵresetCompiledComponents, ɵsetUnknownElementStrictMode, ɵsetUnknownPropertyStrictMode, ɵgetUnknownElementStrictMode, ɵgetUnknownPropertyStrictMode, runInInjectionContext, EnvironmentInjector, ɵ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';
|
|
@@ -51,6 +51,8 @@ function waitForAsync(fn) {
|
|
|
51
51
|
* @publicApi
|
|
52
52
|
*/
|
|
53
53
|
class DeferBlockFixture {
|
|
54
|
+
block;
|
|
55
|
+
componentFixture;
|
|
54
56
|
/** @nodoc */
|
|
55
57
|
constructor(block, componentFixture) {
|
|
56
58
|
this.block = block;
|
|
@@ -150,11 +152,9 @@ const ComponentFixtureNoNgZone = new InjectionToken('ComponentFixtureNoNgZone');
|
|
|
150
152
|
|
|
151
153
|
const RETHROW_APPLICATION_ERRORS_DEFAULT = true;
|
|
152
154
|
class TestBedApplicationErrorHandler {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this.whenStableRejectFunctions = new Set();
|
|
157
|
-
}
|
|
155
|
+
zone = inject$1(NgZone);
|
|
156
|
+
userErrorHandler = inject$1(ErrorHandler);
|
|
157
|
+
whenStableRejectFunctions = new Set();
|
|
158
158
|
handleError(e) {
|
|
159
159
|
try {
|
|
160
160
|
this.zone.runOutsideAngular(() => this.userErrorHandler.handleError(e));
|
|
@@ -175,10 +175,10 @@ class TestBedApplicationErrorHandler {
|
|
|
175
175
|
throw e;
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
|
-
static
|
|
179
|
-
static
|
|
178
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: TestBedApplicationErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
179
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: TestBedApplicationErrorHandler });
|
|
180
180
|
}
|
|
181
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-rc.0", ngImport: i0, type: TestBedApplicationErrorHandler, decorators: [{
|
|
182
182
|
type: Injectable
|
|
183
183
|
}] });
|
|
184
184
|
|
|
@@ -188,34 +188,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0-next.8",
|
|
|
188
188
|
* @publicApi
|
|
189
189
|
*/
|
|
190
190
|
class ComponentFixture {
|
|
191
|
+
componentRef;
|
|
192
|
+
/**
|
|
193
|
+
* The DebugElement associated with the root element of this component.
|
|
194
|
+
*/
|
|
195
|
+
debugElement;
|
|
196
|
+
/**
|
|
197
|
+
* The instance of the root component class.
|
|
198
|
+
*/
|
|
199
|
+
componentInstance;
|
|
200
|
+
/**
|
|
201
|
+
* The native element at the root of the component.
|
|
202
|
+
*/
|
|
203
|
+
nativeElement;
|
|
204
|
+
/**
|
|
205
|
+
* The ElementRef for the element at the root of the component.
|
|
206
|
+
*/
|
|
207
|
+
elementRef;
|
|
208
|
+
/**
|
|
209
|
+
* The ChangeDetectorRef for the component
|
|
210
|
+
*/
|
|
211
|
+
changeDetectorRef;
|
|
212
|
+
_renderer;
|
|
213
|
+
_isDestroyed = false;
|
|
214
|
+
/** @internal */
|
|
215
|
+
_noZoneOptionIsSet = inject$1(ComponentFixtureNoNgZone, { optional: true });
|
|
216
|
+
/** @internal */
|
|
217
|
+
_ngZone = this._noZoneOptionIsSet ? new ɵNoopNgZone() : inject$1(NgZone);
|
|
218
|
+
// Inject ApplicationRef to ensure NgZone stableness causes after render hooks to run
|
|
219
|
+
// This will likely happen as a result of fixture.detectChanges because it calls ngZone.run
|
|
220
|
+
// This is a crazy way of doing things but hey, it's the world we live in.
|
|
221
|
+
// The zoneless scheduler should instead do this more imperatively by attaching
|
|
222
|
+
// the `ComponentRef` to `ApplicationRef` and calling `appRef.tick` as the `detectChanges`
|
|
223
|
+
// behavior.
|
|
224
|
+
/** @internal */
|
|
225
|
+
_appRef = inject$1(ApplicationRef);
|
|
226
|
+
_testAppRef = this._appRef;
|
|
227
|
+
pendingTasks = inject$1(ɵPendingTasks);
|
|
228
|
+
appErrorHandler = inject$1(TestBedApplicationErrorHandler);
|
|
229
|
+
zonelessEnabled = inject$1(ɵZONELESS_ENABLED);
|
|
230
|
+
scheduler = inject$1(ɵChangeDetectionScheduler);
|
|
231
|
+
rootEffectScheduler = inject$1(ɵEffectScheduler);
|
|
232
|
+
microtaskEffectScheduler = inject$1(ɵMicrotaskEffectScheduler);
|
|
233
|
+
autoDetectDefault = this.zonelessEnabled ? true : false;
|
|
234
|
+
autoDetect = inject$1(ComponentFixtureAutoDetect, { optional: true }) ?? this.autoDetectDefault;
|
|
235
|
+
subscriptions = new Subscription();
|
|
236
|
+
// TODO(atscott): Remove this from public API
|
|
237
|
+
ngZone = this._noZoneOptionIsSet ? null : this._ngZone;
|
|
191
238
|
/** @nodoc */
|
|
192
239
|
constructor(componentRef) {
|
|
193
240
|
this.componentRef = componentRef;
|
|
194
|
-
this._isDestroyed = false;
|
|
195
|
-
/** @internal */
|
|
196
|
-
this._noZoneOptionIsSet = inject$1(ComponentFixtureNoNgZone, { optional: true });
|
|
197
|
-
/** @internal */
|
|
198
|
-
this._ngZone = this._noZoneOptionIsSet ? new ɵNoopNgZone() : inject$1(NgZone);
|
|
199
|
-
// Inject ApplicationRef to ensure NgZone stableness causes after render hooks to run
|
|
200
|
-
// This will likely happen as a result of fixture.detectChanges because it calls ngZone.run
|
|
201
|
-
// This is a crazy way of doing things but hey, it's the world we live in.
|
|
202
|
-
// The zoneless scheduler should instead do this more imperatively by attaching
|
|
203
|
-
// the `ComponentRef` to `ApplicationRef` and calling `appRef.tick` as the `detectChanges`
|
|
204
|
-
// behavior.
|
|
205
|
-
/** @internal */
|
|
206
|
-
this._appRef = inject$1(ApplicationRef);
|
|
207
|
-
this._testAppRef = this._appRef;
|
|
208
|
-
this.pendingTasks = inject$1(ɵPendingTasks);
|
|
209
|
-
this.appErrorHandler = inject$1(TestBedApplicationErrorHandler);
|
|
210
|
-
this.zonelessEnabled = inject$1(ɵZONELESS_ENABLED);
|
|
211
|
-
this.scheduler = inject$1(ɵChangeDetectionScheduler);
|
|
212
|
-
this.rootEffectScheduler = inject$1(ɵEffectScheduler);
|
|
213
|
-
this.microtaskEffectScheduler = inject$1(ɵMicrotaskEffectScheduler);
|
|
214
|
-
this.autoDetectDefault = this.zonelessEnabled ? true : false;
|
|
215
|
-
this.autoDetect = inject$1(ComponentFixtureAutoDetect, { optional: true }) ?? this.autoDetectDefault;
|
|
216
|
-
this.subscriptions = new Subscription();
|
|
217
|
-
// TODO(atscott): Remove this from public API
|
|
218
|
-
this.ngZone = this._noZoneOptionIsSet ? null : this._ngZone;
|
|
219
241
|
this.changeDetectorRef = componentRef.changeDetectorRef;
|
|
220
242
|
this.elementRef = componentRef.location;
|
|
221
243
|
this.debugElement = getDebugNode(this.elementRef.nativeElement);
|
|
@@ -287,6 +309,8 @@ class ComponentFixture {
|
|
|
287
309
|
* Set whether the fixture should autodetect changes.
|
|
288
310
|
*
|
|
289
311
|
* Also runs detectChanges once so that any existing change is detected.
|
|
312
|
+
*
|
|
313
|
+
* @param autoDetect Whether to autodetect changes. By default, `true`.
|
|
290
314
|
*/
|
|
291
315
|
autoDetectChanges(autoDetect = true) {
|
|
292
316
|
if (this._noZoneOptionIsSet && !this.zonelessEnabled) {
|
|
@@ -535,9 +559,7 @@ function flushMicrotasks() {
|
|
|
535
559
|
|
|
536
560
|
let _nextReferenceId = 0;
|
|
537
561
|
class MetadataOverrider {
|
|
538
|
-
|
|
539
|
-
this._references = new Map();
|
|
540
|
-
}
|
|
562
|
+
_references = new Map();
|
|
541
563
|
/**
|
|
542
564
|
* Creates a new instance for the given metadata class
|
|
543
565
|
* based on an old instance and overrides.
|
|
@@ -659,10 +681,8 @@ const reflection = new ɵReflectionCapabilities();
|
|
|
659
681
|
* Allows to override ivy metadata for tests (via the `TestBed`).
|
|
660
682
|
*/
|
|
661
683
|
class OverrideResolver {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
this.resolved = new Map();
|
|
665
|
-
}
|
|
684
|
+
overrides = new Map();
|
|
685
|
+
resolved = new Map();
|
|
666
686
|
addOverride(type, override) {
|
|
667
687
|
const overrides = this.overrides.get(type) || [];
|
|
668
688
|
overrides.push(override);
|
|
@@ -745,67 +765,70 @@ function assertNoStandaloneComponents(types, resolver, location) {
|
|
|
745
765
|
types.forEach((type) => {
|
|
746
766
|
if (!ɵgetAsyncClassMetadataFn(type)) {
|
|
747
767
|
const component = resolver.resolve(type);
|
|
748
|
-
if (component && component.standalone) {
|
|
768
|
+
if (component && (component.standalone ?? ɵNG_STANDALONE_DEFAULT_VALUE)) {
|
|
749
769
|
throw new Error(ɵgenerateStandaloneInDeclarationsError(type, location));
|
|
750
770
|
}
|
|
751
771
|
}
|
|
752
772
|
});
|
|
753
773
|
}
|
|
754
774
|
class TestBedCompiler {
|
|
775
|
+
platform;
|
|
776
|
+
additionalModuleTypes;
|
|
777
|
+
originalComponentResolutionQueue = null;
|
|
778
|
+
// Testing module configuration
|
|
779
|
+
declarations = [];
|
|
780
|
+
imports = [];
|
|
781
|
+
providers = [];
|
|
782
|
+
schemas = [];
|
|
783
|
+
// Queues of components/directives/pipes that should be recompiled.
|
|
784
|
+
pendingComponents = new Set();
|
|
785
|
+
pendingDirectives = new Set();
|
|
786
|
+
pendingPipes = new Set();
|
|
787
|
+
// Set of components with async metadata, i.e. components with `@defer` blocks
|
|
788
|
+
// in their templates.
|
|
789
|
+
componentsWithAsyncMetadata = new Set();
|
|
790
|
+
// Keep track of all components and directives, so we can patch Providers onto defs later.
|
|
791
|
+
seenComponents = new Set();
|
|
792
|
+
seenDirectives = new Set();
|
|
793
|
+
// Keep track of overridden modules, so that we can collect all affected ones in the module tree.
|
|
794
|
+
overriddenModules = new Set();
|
|
795
|
+
// Store resolved styles for Components that have template overrides present and `styleUrls`
|
|
796
|
+
// defined at the same time.
|
|
797
|
+
existingComponentStyles = new Map();
|
|
798
|
+
resolvers = initResolvers();
|
|
799
|
+
// Map of component type to an NgModule that declares it.
|
|
800
|
+
//
|
|
801
|
+
// There are a couple special cases:
|
|
802
|
+
// - for standalone components, the module scope value is `null`
|
|
803
|
+
// - when a component is declared in `TestBed.configureTestingModule()` call or
|
|
804
|
+
// a component's template is overridden via `TestBed.overrideTemplateUsingTestingModule()`.
|
|
805
|
+
// we use a special value from the `TestingModuleOverride` enum.
|
|
806
|
+
componentToModuleScope = new Map();
|
|
807
|
+
// Map that keeps initial version of component/directive/pipe defs in case
|
|
808
|
+
// we compile a Type again, thus overriding respective static fields. This is
|
|
809
|
+
// required to make sure we restore defs to their initial states between test runs.
|
|
810
|
+
// Note: one class may have multiple defs (for example: ɵmod and ɵinj in case of an
|
|
811
|
+
// NgModule), store all of them in a map.
|
|
812
|
+
initialNgDefs = new Map();
|
|
813
|
+
// Array that keeps cleanup operations for initial versions of component/directive/pipe/module
|
|
814
|
+
// defs in case TestBed makes changes to the originals.
|
|
815
|
+
defCleanupOps = [];
|
|
816
|
+
_injector = null;
|
|
817
|
+
compilerProviders = null;
|
|
818
|
+
providerOverrides = [];
|
|
819
|
+
rootProviderOverrides = [];
|
|
820
|
+
// Overrides for injectables with `{providedIn: SomeModule}` need to be tracked and added to that
|
|
821
|
+
// module's provider list.
|
|
822
|
+
providerOverridesByModule = new Map();
|
|
823
|
+
providerOverridesByToken = new Map();
|
|
824
|
+
scopesWithOverriddenProviders = new Set();
|
|
825
|
+
testModuleType;
|
|
826
|
+
testModuleRef = null;
|
|
827
|
+
deferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
|
|
828
|
+
rethrowApplicationTickErrors = RETHROW_APPLICATION_ERRORS_DEFAULT;
|
|
755
829
|
constructor(platform, additionalModuleTypes) {
|
|
756
830
|
this.platform = platform;
|
|
757
831
|
this.additionalModuleTypes = additionalModuleTypes;
|
|
758
|
-
this.originalComponentResolutionQueue = null;
|
|
759
|
-
// Testing module configuration
|
|
760
|
-
this.declarations = [];
|
|
761
|
-
this.imports = [];
|
|
762
|
-
this.providers = [];
|
|
763
|
-
this.schemas = [];
|
|
764
|
-
// Queues of components/directives/pipes that should be recompiled.
|
|
765
|
-
this.pendingComponents = new Set();
|
|
766
|
-
this.pendingDirectives = new Set();
|
|
767
|
-
this.pendingPipes = new Set();
|
|
768
|
-
// Set of components with async metadata, i.e. components with `@defer` blocks
|
|
769
|
-
// in their templates.
|
|
770
|
-
this.componentsWithAsyncMetadata = new Set();
|
|
771
|
-
// Keep track of all components and directives, so we can patch Providers onto defs later.
|
|
772
|
-
this.seenComponents = new Set();
|
|
773
|
-
this.seenDirectives = new Set();
|
|
774
|
-
// Keep track of overridden modules, so that we can collect all affected ones in the module tree.
|
|
775
|
-
this.overriddenModules = new Set();
|
|
776
|
-
// Store resolved styles for Components that have template overrides present and `styleUrls`
|
|
777
|
-
// defined at the same time.
|
|
778
|
-
this.existingComponentStyles = new Map();
|
|
779
|
-
this.resolvers = initResolvers();
|
|
780
|
-
// Map of component type to an NgModule that declares it.
|
|
781
|
-
//
|
|
782
|
-
// There are a couple special cases:
|
|
783
|
-
// - for standalone components, the module scope value is `null`
|
|
784
|
-
// - when a component is declared in `TestBed.configureTestingModule()` call or
|
|
785
|
-
// a component's template is overridden via `TestBed.overrideTemplateUsingTestingModule()`.
|
|
786
|
-
// we use a special value from the `TestingModuleOverride` enum.
|
|
787
|
-
this.componentToModuleScope = new Map();
|
|
788
|
-
// Map that keeps initial version of component/directive/pipe defs in case
|
|
789
|
-
// we compile a Type again, thus overriding respective static fields. This is
|
|
790
|
-
// required to make sure we restore defs to their initial states between test runs.
|
|
791
|
-
// Note: one class may have multiple defs (for example: ɵmod and ɵinj in case of an
|
|
792
|
-
// NgModule), store all of them in a map.
|
|
793
|
-
this.initialNgDefs = new Map();
|
|
794
|
-
// Array that keeps cleanup operations for initial versions of component/directive/pipe/module
|
|
795
|
-
// defs in case TestBed makes changes to the originals.
|
|
796
|
-
this.defCleanupOps = [];
|
|
797
|
-
this._injector = null;
|
|
798
|
-
this.compilerProviders = null;
|
|
799
|
-
this.providerOverrides = [];
|
|
800
|
-
this.rootProviderOverrides = [];
|
|
801
|
-
// Overrides for injectables with `{providedIn: SomeModule}` need to be tracked and added to that
|
|
802
|
-
// module's provider list.
|
|
803
|
-
this.providerOverridesByModule = new Map();
|
|
804
|
-
this.providerOverridesByToken = new Map();
|
|
805
|
-
this.scopesWithOverriddenProviders = new Set();
|
|
806
|
-
this.testModuleRef = null;
|
|
807
|
-
this.deferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
|
|
808
|
-
this.rethrowApplicationTickErrors = RETHROW_APPLICATION_ERRORS_DEFAULT;
|
|
809
832
|
class DynamicTestModule {
|
|
810
833
|
}
|
|
811
834
|
this.testModuleType = DynamicTestModule;
|
|
@@ -1632,6 +1655,7 @@ function invalidTypeError(name, expectedType) {
|
|
|
1632
1655
|
return new Error(`${name} class doesn't have @${expectedType} decorator or is missing metadata.`);
|
|
1633
1656
|
}
|
|
1634
1657
|
class R3TestCompiler {
|
|
1658
|
+
testBed;
|
|
1635
1659
|
constructor(testBed) {
|
|
1636
1660
|
this.testBed = testBed;
|
|
1637
1661
|
}
|
|
@@ -1679,29 +1703,55 @@ function getTestBed() {
|
|
|
1679
1703
|
* TestBed is the primary api for writing unit tests for Angular applications and libraries.
|
|
1680
1704
|
*/
|
|
1681
1705
|
class TestBedImpl {
|
|
1682
|
-
|
|
1683
|
-
/**
|
|
1684
|
-
* Defer block behavior option that specifies whether defer blocks will be triggered manually
|
|
1685
|
-
* or set to play through.
|
|
1686
|
-
*/
|
|
1687
|
-
this._instanceDeferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
|
|
1688
|
-
// Properties
|
|
1689
|
-
this.platform = null;
|
|
1690
|
-
this.ngModule = null;
|
|
1691
|
-
this._compiler = null;
|
|
1692
|
-
this._testModuleRef = null;
|
|
1693
|
-
this._activeFixtures = [];
|
|
1694
|
-
/**
|
|
1695
|
-
* Internal-only flag to indicate whether a module
|
|
1696
|
-
* scoping queue has been checked and flushed already.
|
|
1697
|
-
* @nodoc
|
|
1698
|
-
*/
|
|
1699
|
-
this.globalCompilationChecked = false;
|
|
1700
|
-
}
|
|
1701
|
-
static { this._INSTANCE = null; }
|
|
1706
|
+
static _INSTANCE = null;
|
|
1702
1707
|
static get INSTANCE() {
|
|
1703
1708
|
return (TestBedImpl._INSTANCE = TestBedImpl._INSTANCE || new TestBedImpl());
|
|
1704
1709
|
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Teardown options that have been configured at the environment level.
|
|
1712
|
+
* Used as a fallback if no instance-level options have been provided.
|
|
1713
|
+
*/
|
|
1714
|
+
static _environmentTeardownOptions;
|
|
1715
|
+
/**
|
|
1716
|
+
* "Error on unknown elements" option that has been configured at the environment level.
|
|
1717
|
+
* Used as a fallback if no instance-level option has been provided.
|
|
1718
|
+
*/
|
|
1719
|
+
static _environmentErrorOnUnknownElementsOption;
|
|
1720
|
+
/**
|
|
1721
|
+
* "Error on unknown properties" option that has been configured at the environment level.
|
|
1722
|
+
* Used as a fallback if no instance-level option has been provided.
|
|
1723
|
+
*/
|
|
1724
|
+
static _environmentErrorOnUnknownPropertiesOption;
|
|
1725
|
+
/**
|
|
1726
|
+
* Teardown options that have been configured at the `TestBed` instance level.
|
|
1727
|
+
* These options take precedence over the environment-level ones.
|
|
1728
|
+
*/
|
|
1729
|
+
_instanceTeardownOptions;
|
|
1730
|
+
/**
|
|
1731
|
+
* Defer block behavior option that specifies whether defer blocks will be triggered manually
|
|
1732
|
+
* or set to play through.
|
|
1733
|
+
*/
|
|
1734
|
+
_instanceDeferBlockBehavior = DEFER_BLOCK_DEFAULT_BEHAVIOR;
|
|
1735
|
+
/**
|
|
1736
|
+
* "Error on unknown elements" option that has been configured at the `TestBed` instance level.
|
|
1737
|
+
* This option takes precedence over the environment-level one.
|
|
1738
|
+
*/
|
|
1739
|
+
_instanceErrorOnUnknownElementsOption;
|
|
1740
|
+
/**
|
|
1741
|
+
* "Error on unknown properties" option that has been configured at the `TestBed` instance level.
|
|
1742
|
+
* This option takes precedence over the environment-level one.
|
|
1743
|
+
*/
|
|
1744
|
+
_instanceErrorOnUnknownPropertiesOption;
|
|
1745
|
+
/**
|
|
1746
|
+
* Stores the previous "Error on unknown elements" option value,
|
|
1747
|
+
* allowing to restore it in the reset testing module logic.
|
|
1748
|
+
*/
|
|
1749
|
+
_previousErrorOnUnknownElementsOption;
|
|
1750
|
+
/**
|
|
1751
|
+
* Stores the previous "Error on unknown properties" option value,
|
|
1752
|
+
* allowing to restore it in the reset testing module logic.
|
|
1753
|
+
*/
|
|
1754
|
+
_previousErrorOnUnknownPropertiesOption;
|
|
1705
1755
|
/**
|
|
1706
1756
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
1707
1757
|
* angular module. These are common to every test in the suite.
|
|
@@ -1806,6 +1856,18 @@ class TestBedImpl {
|
|
|
1806
1856
|
static flushEffects() {
|
|
1807
1857
|
return TestBedImpl.INSTANCE.flushEffects();
|
|
1808
1858
|
}
|
|
1859
|
+
// Properties
|
|
1860
|
+
platform = null;
|
|
1861
|
+
ngModule = null;
|
|
1862
|
+
_compiler = null;
|
|
1863
|
+
_testModuleRef = null;
|
|
1864
|
+
_activeFixtures = [];
|
|
1865
|
+
/**
|
|
1866
|
+
* Internal-only flag to indicate whether a module
|
|
1867
|
+
* scoping queue has been checked and flushed already.
|
|
1868
|
+
* @nodoc
|
|
1869
|
+
*/
|
|
1870
|
+
globalCompilationChecked = false;
|
|
1809
1871
|
/**
|
|
1810
1872
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
1811
1873
|
* angular module. These are common to every test in the suite.
|
|
@@ -2172,6 +2234,7 @@ function inject(tokens, fn) {
|
|
|
2172
2234
|
* @publicApi
|
|
2173
2235
|
*/
|
|
2174
2236
|
class InjectSetupWrapper {
|
|
2237
|
+
_moduleDef;
|
|
2175
2238
|
constructor(_moduleDef) {
|
|
2176
2239
|
this._moduleDef = _moduleDef;
|
|
2177
2240
|
}
|