UNPKG

@angular/core

Version:

Angular - the core framework

843 lines 124 kB
/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { __assign, __awaiter, __generator, __read, __spread, __values } from "tslib"; import { ResourceLoader } from '@angular/compiler'; import { ApplicationInitStatus, Compiler, COMPILER_OPTIONS, LOCALE_ID, ModuleWithComponentFactories, NgZone, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵDEFAULT_LOCALE_ID as DEFAULT_LOCALE_ID, ɵgetInjectableDef as getInjectableDef, ɵNG_COMP_DEF as NG_COMP_DEF, ɵNG_DIR_DEF as NG_DIR_DEF, ɵNG_INJ_DEF as NG_INJ_DEF, ɵNG_MOD_DEF as NG_MOD_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleFactory as R3NgModuleFactory, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵsetLocaleId as setLocaleId, ɵtransitiveScopesFor as transitiveScopesFor } from '@angular/core'; import { clearResolutionOfComponentResourcesQueue, isComponentDefPendingResolution, resolveComponentResources, restoreComponentResolutionQueue } from '../../src/metadata/resource_loading'; import { ComponentResolver, DirectiveResolver, NgModuleResolver, PipeResolver } from './resolvers'; var TestingModuleOverride; (function (TestingModuleOverride) { TestingModuleOverride[TestingModuleOverride["DECLARATION"] = 0] = "DECLARATION"; TestingModuleOverride[TestingModuleOverride["OVERRIDE_TEMPLATE"] = 1] = "OVERRIDE_TEMPLATE"; })(TestingModuleOverride || (TestingModuleOverride = {})); function isTestingModuleOverride(value) { return value === TestingModuleOverride.DECLARATION || value === TestingModuleOverride.OVERRIDE_TEMPLATE; } var R3TestBedCompiler = /** @class */ (function () { function R3TestBedCompiler(platform, additionalModuleTypes) { this.platform = platform; this.additionalModuleTypes = additionalModuleTypes; this.originalComponentResolutionQueue = null; // Testing module configuration this.declarations = []; this.imports = []; this.providers = []; this.schemas = []; // Queues of components/directives/pipes that should be recompiled. this.pendingComponents = new Set(); this.pendingDirectives = new Set(); this.pendingPipes = new Set(); // Keep track of all components and directives, so we can patch Providers onto defs later. this.seenComponents = new Set(); this.seenDirectives = new Set(); // Keep track of overridden modules, so that we can collect all affected ones in the module tree. this.overriddenModules = new Set(); // Store resolved styles for Components that have template overrides present and `styleUrls` // defined at the same time. this.existingComponentStyles = new Map(); this.resolvers = initResolvers(); this.componentToModuleScope = new Map(); // Map that keeps initial version of component/directive/pipe defs in case // we compile a Type again, thus overriding respective static fields. This is // required to make sure we restore defs to their initial states between test runs // TODO: we should support the case with multiple defs on a type this.initialNgDefs = new Map(); // Array that keeps cleanup operations for initial versions of component/directive/pipe/module // defs in case TestBed makes changes to the originals. this.defCleanupOps = []; this._injector = null; this.compilerProviders = null; this.providerOverrides = []; this.rootProviderOverrides = []; // Overrides for injectables with `{providedIn: SomeModule}` need to be tracked and added to that // module's provider list. this.providerOverridesByModule = new Map(); this.providerOverridesByToken = new Map(); this.moduleProvidersOverridden = new Set(); this.testModuleRef = null; var DynamicTestModule = /** @class */ (function () { function DynamicTestModule() { } return DynamicTestModule; }()); this.testModuleType = DynamicTestModule; } R3TestBedCompiler.prototype.setCompilerProviders = function (providers) { this.compilerProviders = providers; this._injector = null; }; R3TestBedCompiler.prototype.configureTestingModule = function (moduleDef) { var _a, _b, _c, _d; // Enqueue any compilation tasks for the directly declared component. if (moduleDef.declarations !== undefined) { this.queueTypeArray(moduleDef.declarations, TestingModuleOverride.DECLARATION); (_a = this.declarations).push.apply(_a, __spread(moduleDef.declarations)); } // Enqueue any compilation tasks for imported modules. if (moduleDef.imports !== undefined) { this.queueTypesFromModulesArray(moduleDef.imports); (_b = this.imports).push.apply(_b, __spread(moduleDef.imports)); } if (moduleDef.providers !== undefined) { (_c = this.providers).push.apply(_c, __spread(moduleDef.providers)); } if (moduleDef.schemas !== undefined) { (_d = this.schemas).push.apply(_d, __spread(moduleDef.schemas)); } }; R3TestBedCompiler.prototype.overrideModule = function (ngModule, override) { this.overriddenModules.add(ngModule); // Compile the module right away. this.resolvers.module.addOverride(ngModule, override); var metadata = this.resolvers.module.resolve(ngModule); if (metadata === null) { throw invalidTypeError(ngModule.name, 'NgModule'); } this.recompileNgModule(ngModule, metadata); // At this point, the module has a valid module def (ɵmod), but the override may have introduced // new declarations or imported modules. Ingest any possible new types and add them to the // current queue. this.queueTypesFromModulesArray([ngModule]); }; R3TestBedCompiler.prototype.overrideComponent = function (component, override) { this.resolvers.component.addOverride(component, override); this.pendingComponents.add(component); }; R3TestBedCompiler.prototype.overrideDirective = function (directive, override) { this.resolvers.directive.addOverride(directive, override); this.pendingDirectives.add(directive); }; R3TestBedCompiler.prototype.overridePipe = function (pipe, override) { this.resolvers.pipe.addOverride(pipe, override); this.pendingPipes.add(pipe); }; R3TestBedCompiler.prototype.overrideProvider = function (token, provider) { var providerDef; if (provider.useFactory !== undefined) { providerDef = { provide: token, useFactory: provider.useFactory, deps: provider.deps || [], multi: provider.multi }; } else if (provider.useValue !== undefined) { providerDef = { provide: token, useValue: provider.useValue, multi: provider.multi }; } else { providerDef = { provide: token }; } var injectableDef = typeof token !== 'string' ? getInjectableDef(token) : null; var isRoot = injectableDef !== null && injectableDef.providedIn === 'root'; var overridesBucket = isRoot ? this.rootProviderOverrides : this.providerOverrides; overridesBucket.push(providerDef); // Keep overrides grouped by token as well for fast lookups using token this.providerOverridesByToken.set(token, providerDef); if (injectableDef !== null && injectableDef.providedIn !== null && typeof injectableDef.providedIn !== 'string') { var existingOverrides = this.providerOverridesByModule.get(injectableDef.providedIn); if (existingOverrides !== undefined) { existingOverrides.push(providerDef); } else { this.providerOverridesByModule.set(injectableDef.providedIn, [providerDef]); } } }; R3TestBedCompiler.prototype.overrideTemplateUsingTestingModule = function (type, template) { var _this = this; var def = type[NG_COMP_DEF]; var hasStyleUrls = function () { var metadata = _this.resolvers.component.resolve(type); return !!metadata.styleUrls && metadata.styleUrls.length > 0; }; var overrideStyleUrls = !!def && !isComponentDefPendingResolution(type) && hasStyleUrls(); // In Ivy, compiling a component does not require knowing the module providing the // component's scope, so overrideTemplateUsingTestingModule can be implemented purely via // overrideComponent. Important: overriding template requires full Component re-compilation, // which may fail in case styleUrls are also present (thus Component is considered as required // resolution). In order to avoid this, we preemptively set styleUrls to an empty array, // preserve current styles available on Component def and restore styles back once compilation // is complete. var override = overrideStyleUrls ? { template: template, styles: [], styleUrls: [] } : { template: template }; this.overrideComponent(type, { set: override }); if (overrideStyleUrls && def.styles && def.styles.length > 0) { this.existingComponentStyles.set(type, def.styles); } // Set the component's scope to be the testing module. this.componentToModuleScope.set(type, TestingModuleOverride.OVERRIDE_TEMPLATE); }; R3TestBedCompiler.prototype.compileComponents = function () { return __awaiter(this, void 0, void 0, function () { var needsAsyncResources, resourceLoader_1, resolver; var _this = this; return __generator(this, function (_a) { switch (_a.label) { case 0: this.clearComponentResolutionQueue(); needsAsyncResources = this.compileTypesSync(); if (!needsAsyncResources) return [3 /*break*/, 2]; resolver = function (url) { if (!resourceLoader_1) { resourceLoader_1 = _this.injector.get(ResourceLoader); } return Promise.resolve(resourceLoader_1.get(url)); }; return [4 /*yield*/, resolveComponentResources(resolver)]; case 1: _a.sent(); _a.label = 2; case 2: return [2 /*return*/]; } }); }); }; R3TestBedCompiler.prototype.finalize = function () { // One last compile this.compileTypesSync(); // Create the testing module itself. this.compileTestModule(); this.applyTransitiveScopes(); this.applyProviderOverrides(); // Patch previously stored `styles` Component values (taken from ɵcmp), in case these // Components have `styleUrls` fields defined and template override was requested. this.patchComponentsWithExistingStyles(); // Clear the componentToModuleScope map, so that future compilations don't reset the scope of // every component. this.componentToModuleScope.clear(); var parentInjector = this.platform.injector; this.testModuleRef = new NgModuleRef(this.testModuleType, parentInjector); // ApplicationInitStatus.runInitializers() is marked @internal to core. // Cast it to any before accessing it. this.testModuleRef.injector.get(ApplicationInitStatus).runInitializers(); // Set locale ID after running app initializers, since locale information might be updated while // running initializers. This is also consistent with the execution order while bootstrapping an // app (see `packages/core/src/application_ref.ts` file). var localeId = this.testModuleRef.injector.get(LOCALE_ID, DEFAULT_LOCALE_ID); setLocaleId(localeId); return this.testModuleRef; }; /** * @internal */ R3TestBedCompiler.prototype._compileNgModuleSync = function (moduleType) { this.queueTypesFromModulesArray([moduleType]); this.compileTypesSync(); this.applyProviderOverrides(); this.applyProviderOverridesToModule(moduleType); this.applyTransitiveScopes(); }; /** * @internal */ R3TestBedCompiler.prototype._compileNgModuleAsync = function (moduleType) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.queueTypesFromModulesArray([moduleType]); return [4 /*yield*/, this.compileComponents()]; case 1: _a.sent(); this.applyProviderOverrides(); this.applyProviderOverridesToModule(moduleType); this.applyTransitiveScopes(); return [2 /*return*/]; } }); }); }; /** * @internal */ R3TestBedCompiler.prototype._getModuleResolver = function () { return this.resolvers.module; }; /** * @internal */ R3TestBedCompiler.prototype._getComponentFactories = function (moduleType) { var _this = this; return maybeUnwrapFn(moduleType.ɵmod.declarations).reduce(function (factories, declaration) { var componentDef = declaration.ɵcmp; componentDef && factories.push(new ComponentFactory(componentDef, _this.testModuleRef)); return factories; }, []); }; R3TestBedCompiler.prototype.compileTypesSync = function () { var _this = this; // Compile all queued components, directives, pipes. var needsAsyncResources = false; this.pendingComponents.forEach(function (declaration) { needsAsyncResources = needsAsyncResources || isComponentDefPendingResolution(declaration); var metadata = _this.resolvers.component.resolve(declaration); if (metadata === null) { throw invalidTypeError(declaration.name, 'Component'); } _this.maybeStoreNgDef(NG_COMP_DEF, declaration); compileComponent(declaration, metadata); }); this.pendingComponents.clear(); this.pendingDirectives.forEach(function (declaration) { var metadata = _this.resolvers.directive.resolve(declaration); if (metadata === null) { throw invalidTypeError(declaration.name, 'Directive'); } _this.maybeStoreNgDef(NG_DIR_DEF, declaration); compileDirective(declaration, metadata); }); this.pendingDirectives.clear(); this.pendingPipes.forEach(function (declaration) { var metadata = _this.resolvers.pipe.resolve(declaration); if (metadata === null) { throw invalidTypeError(declaration.name, 'Pipe'); } _this.maybeStoreNgDef(NG_PIPE_DEF, declaration); compilePipe(declaration, metadata); }); this.pendingPipes.clear(); return needsAsyncResources; }; R3TestBedCompiler.prototype.applyTransitiveScopes = function () { var _this = this; if (this.overriddenModules.size > 0) { // Module overrides (via `TestBed.overrideModule`) might affect scopes that were previously // calculated and stored in `transitiveCompileScopes`. If module overrides are present, // collect all affected modules and reset scopes to force their re-calculatation. var testingModuleDef = this.testModuleType[NG_MOD_DEF]; var affectedModules = this.collectModulesAffectedByOverrides(testingModuleDef.imports); if (affectedModules.size > 0) { affectedModules.forEach(function (moduleType) { _this.storeFieldOfDefOnType(moduleType, NG_MOD_DEF, 'transitiveCompileScopes'); moduleType[NG_MOD_DEF].transitiveCompileScopes = null; }); } } var moduleToScope = new Map(); var getScopeOfModule = function (moduleType) { if (!moduleToScope.has(moduleType)) { var isTestingModule = isTestingModuleOverride(moduleType); var realType = isTestingModule ? _this.testModuleType : moduleType; moduleToScope.set(moduleType, transitiveScopesFor(realType)); } return moduleToScope.get(moduleType); }; this.componentToModuleScope.forEach(function (moduleType, componentType) { var moduleScope = getScopeOfModule(moduleType); _this.storeFieldOfDefOnType(componentType, NG_COMP_DEF, 'directiveDefs'); _this.storeFieldOfDefOnType(componentType, NG_COMP_DEF, 'pipeDefs'); patchComponentDefWithScope(componentType.ɵcmp, moduleScope); }); this.componentToModuleScope.clear(); }; R3TestBedCompiler.prototype.applyProviderOverrides = function () { var _this = this; var maybeApplyOverrides = function (field) { return function (type) { var resolver = field === NG_COMP_DEF ? _this.resolvers.component : _this.resolvers.directive; var metadata = resolver.resolve(type); if (_this.hasProviderOverrides(metadata.providers)) { _this.patchDefWithProviderOverrides(type, field); } }; }; this.seenComponents.forEach(maybeApplyOverrides(NG_COMP_DEF)); this.seenDirectives.forEach(maybeApplyOverrides(NG_DIR_DEF)); this.seenComponents.clear(); this.seenDirectives.clear(); }; R3TestBedCompiler.prototype.applyProviderOverridesToModule = function (moduleType) { var e_1, _a, e_2, _b; if (this.moduleProvidersOverridden.has(moduleType)) { return; } this.moduleProvidersOverridden.add(moduleType); var injectorDef = moduleType[NG_INJ_DEF]; if (this.providerOverridesByToken.size > 0) { var providers = __spread(injectorDef.providers, (this.providerOverridesByModule.get(moduleType) || [])); if (this.hasProviderOverrides(providers)) { this.maybeStoreNgDef(NG_INJ_DEF, moduleType); this.storeFieldOfDefOnType(moduleType, NG_INJ_DEF, 'providers'); injectorDef.providers = this.getOverriddenProviders(providers); } // Apply provider overrides to imported modules recursively var moduleDef = moduleType[NG_MOD_DEF]; var imports = maybeUnwrapFn(moduleDef.imports); try { for (var imports_1 = __values(imports), imports_1_1 = imports_1.next(); !imports_1_1.done; imports_1_1 = imports_1.next()) { var importedModule = imports_1_1.value; this.applyProviderOverridesToModule(importedModule); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (imports_1_1 && !imports_1_1.done && (_a = imports_1.return)) _a.call(imports_1); } finally { if (e_1) throw e_1.error; } } try { // Also override the providers on any ModuleWithProviders imports since those don't appear in // the moduleDef. for (var _c = __values(flatten(injectorDef.imports)), _d = _c.next(); !_d.done; _d = _c.next()) { var importedModule = _d.value; if (isModuleWithProviders(importedModule)) { this.defCleanupOps.push({ object: importedModule, fieldName: 'providers', originalValue: importedModule.providers }); importedModule.providers = this.getOverriddenProviders(importedModule.providers); } } } catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_d && !_d.done && (_b = _c.return)) _b.call(_c); } finally { if (e_2) throw e_2.error; } } } }; R3TestBedCompiler.prototype.patchComponentsWithExistingStyles = function () { this.existingComponentStyles.forEach(function (styles, type) { return type[NG_COMP_DEF].styles = styles; }); this.existingComponentStyles.clear(); }; R3TestBedCompiler.prototype.queueTypeArray = function (arr, moduleType) { var e_3, _a; try { for (var arr_1 = __values(arr), arr_1_1 = arr_1.next(); !arr_1_1.done; arr_1_1 = arr_1.next()) { var value = arr_1_1.value; if (Array.isArray(value)) { this.queueTypeArray(value, moduleType); } else { this.queueType(value, moduleType); } } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1); } finally { if (e_3) throw e_3.error; } } }; R3TestBedCompiler.prototype.recompileNgModule = function (ngModule, metadata) { // Cache the initial ngModuleDef as it will be overwritten. this.maybeStoreNgDef(NG_MOD_DEF, ngModule); this.maybeStoreNgDef(NG_INJ_DEF, ngModule); compileNgModuleDefs(ngModule, metadata); }; R3TestBedCompiler.prototype.queueType = function (type, moduleType) { var component = this.resolvers.component.resolve(type); if (component) { // Check whether a give Type has respective NG def (ɵcmp) and compile if def is // missing. That might happen in case a class without any Angular decorators extends another // class where Component/Directive/Pipe decorator is defined. if (isComponentDefPendingResolution(type) || !type.hasOwnProperty(NG_COMP_DEF)) { this.pendingComponents.add(type); } this.seenComponents.add(type); // Keep track of the module which declares this component, so later the component's scope // can be set correctly. If the component has already been recorded here, then one of several // cases is true: // * the module containing the component was imported multiple times (common). // * the component is declared in multiple modules (which is an error). // * the component was in 'declarations' of the testing module, and also in an imported module // in which case the module scope will be TestingModuleOverride.DECLARATION. // * overrideTemplateUsingTestingModule was called for the component in which case the module // scope will be TestingModuleOverride.OVERRIDE_TEMPLATE. // // If the component was previously in the testing module's 'declarations' (meaning the // current value is TestingModuleOverride.DECLARATION), then `moduleType` is the component's // real module, which was imported. This pattern is understood to mean that the component // should use its original scope, but that the testing module should also contain the // component in its scope. if (!this.componentToModuleScope.has(type) || this.componentToModuleScope.get(type) === TestingModuleOverride.DECLARATION) { this.componentToModuleScope.set(type, moduleType); } return; } var directive = this.resolvers.directive.resolve(type); if (directive) { if (!type.hasOwnProperty(NG_DIR_DEF)) { this.pendingDirectives.add(type); } this.seenDirectives.add(type); return; } var pipe = this.resolvers.pipe.resolve(type); if (pipe && !type.hasOwnProperty(NG_PIPE_DEF)) { this.pendingPipes.add(type); return; } }; R3TestBedCompiler.prototype.queueTypesFromModulesArray = function (arr) { var _this = this; // Because we may encounter the same NgModule while processing the imports and exports of an // NgModule tree, we cache them in this set so we can skip ones that have already been seen // encountered. In some test setups, this caching resulted in 10X runtime improvement. var processedNgModuleDefs = new Set(); var queueTypesFromModulesArrayRecur = function (arr) { var e_4, _a; try { for (var arr_2 = __values(arr), arr_2_1 = arr_2.next(); !arr_2_1.done; arr_2_1 = arr_2.next()) { var value = arr_2_1.value; if (Array.isArray(value)) { queueTypesFromModulesArrayRecur(value); } else if (hasNgModuleDef(value)) { var def = value.ɵmod; if (processedNgModuleDefs.has(def)) { continue; } processedNgModuleDefs.add(def); // Look through declarations, imports, and exports, and queue // everything found there. _this.queueTypeArray(maybeUnwrapFn(def.declarations), value); queueTypesFromModulesArrayRecur(maybeUnwrapFn(def.imports)); queueTypesFromModulesArrayRecur(maybeUnwrapFn(def.exports)); } } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { if (arr_2_1 && !arr_2_1.done && (_a = arr_2.return)) _a.call(arr_2); } finally { if (e_4) throw e_4.error; } } }; queueTypesFromModulesArrayRecur(arr); }; // When module overrides (via `TestBed.overrideModule`) are present, it might affect all modules // that import (even transitively) an overridden one. For all affected modules we need to // recalculate their scopes for a given test run and restore original scopes at the end. The goal // of this function is to collect all affected modules in a set for further processing. Example: // if we have the following module hierarchy: A -> B -> C (where `->` means `imports`) and module // `C` is overridden, we consider `A` and `B` as affected, since their scopes might become // invalidated with the override. R3TestBedCompiler.prototype.collectModulesAffectedByOverrides = function (arr) { var _this = this; var seenModules = new Set(); var affectedModules = new Set(); var calcAffectedModulesRecur = function (arr, path) { var e_5, _a; try { for (var arr_3 = __values(arr), arr_3_1 = arr_3.next(); !arr_3_1.done; arr_3_1 = arr_3.next()) { var value = arr_3_1.value; if (Array.isArray(value)) { // If the value is an array, just flatten it (by invoking this function recursively), // keeping "path" the same. calcAffectedModulesRecur(value, path); } else if (hasNgModuleDef(value)) { if (seenModules.has(value)) { // If we've seen this module before and it's included into "affected modules" list, mark // the whole path that leads to that module as affected, but do not descend into its // imports, since we already examined them before. if (affectedModules.has(value)) { path.forEach(function (item) { return affectedModules.add(item); }); } continue; } seenModules.add(value); if (_this.overriddenModules.has(value)) { path.forEach(function (item) { return affectedModules.add(item); }); } // Examine module imports recursively to look for overridden modules. var moduleDef = value[NG_MOD_DEF]; calcAffectedModulesRecur(maybeUnwrapFn(moduleDef.imports), path.concat(value)); } } } catch (e_5_1) { e_5 = { error: e_5_1 }; } finally { try { if (arr_3_1 && !arr_3_1.done && (_a = arr_3.return)) _a.call(arr_3); } finally { if (e_5) throw e_5.error; } } }; calcAffectedModulesRecur(arr, []); return affectedModules; }; R3TestBedCompiler.prototype.maybeStoreNgDef = function (prop, type) { if (!this.initialNgDefs.has(type)) { var currentDef = Object.getOwnPropertyDescriptor(type, prop); this.initialNgDefs.set(type, [prop, currentDef]); } }; R3TestBedCompiler.prototype.storeFieldOfDefOnType = function (type, defField, fieldName) { var def = type[defField]; var originalValue = def[fieldName]; this.defCleanupOps.push({ object: def, fieldName: fieldName, originalValue: originalValue }); }; /** * Clears current components resolution queue, but stores the state of the queue, so we can * restore it later. Clearing the queue is required before we try to compile components (via * `TestBed.compileComponents`), so that component defs are in sync with the resolution queue. */ R3TestBedCompiler.prototype.clearComponentResolutionQueue = function () { var _this = this; if (this.originalComponentResolutionQueue === null) { this.originalComponentResolutionQueue = new Map(); } clearResolutionOfComponentResourcesQueue().forEach(function (value, key) { return _this.originalComponentResolutionQueue.set(key, value); }); }; /* * Restores component resolution queue to the previously saved state. This operation is performed * as a part of restoring the state after completion of the current set of tests (that might * potentially mutate the state). */ R3TestBedCompiler.prototype.restoreComponentResolutionQueue = function () { if (this.originalComponentResolutionQueue !== null) { restoreComponentResolutionQueue(this.originalComponentResolutionQueue); this.originalComponentResolutionQueue = null; } }; R3TestBedCompiler.prototype.restoreOriginalState = function () { // Process cleanup ops in reverse order so the field's original value is restored correctly (in // case there were multiple overrides for the same field). forEachRight(this.defCleanupOps, function (op) { op.object[op.fieldName] = op.originalValue; }); // Restore initial component/directive/pipe defs this.initialNgDefs.forEach(function (value, type) { var _a = __read(value, 2), prop = _a[0], descriptor = _a[1]; if (!descriptor) { // Delete operations are generally undesirable since they have performance implications // on objects they were applied to. In this particular case, situations where this code // is invoked should be quite rare to cause any noticeable impact, since it's applied // only to some test cases (for example when class with no annotations extends some // @Component) when we need to clear 'ɵcmp' field on a given class to restore // its original state (before applying overrides and running tests). delete type[prop]; } else { Object.defineProperty(type, prop, descriptor); } }); this.initialNgDefs.clear(); this.moduleProvidersOverridden.clear(); this.restoreComponentResolutionQueue(); // Restore the locale ID to the default value, this shouldn't be necessary but we never know setLocaleId(DEFAULT_LOCALE_ID); }; R3TestBedCompiler.prototype.compileTestModule = function () { var _this = this; var RootScopeModule = /** @class */ (function () { function RootScopeModule() { } return RootScopeModule; }()); compileNgModuleDefs(RootScopeModule, { providers: __spread(this.rootProviderOverrides), }); var ngZone = new NgZone({ enableLongStackTrace: true }); var providers = __spread([ { provide: NgZone, useValue: ngZone }, { provide: Compiler, useFactory: function () { return new R3TestCompiler(_this); } } ], this.providers, this.providerOverrides); var imports = [RootScopeModule, this.additionalModuleTypes, this.imports || []]; // clang-format off compileNgModuleDefs(this.testModuleType, { declarations: this.declarations, imports: imports, schemas: this.schemas, providers: providers, }, /* allowDuplicateDeclarationsInRoot */ true); // clang-format on this.applyProviderOverridesToModule(this.testModuleType); }; Object.defineProperty(R3TestBedCompiler.prototype, "injector", { get: function () { if (this._injector !== null) { return this._injector; } var providers = []; var compilerOptions = this.platform.injector.get(COMPILER_OPTIONS); compilerOptions.forEach(function (opts) { if (opts.providers) { providers.push(opts.providers); } }); if (this.compilerProviders !== null) { providers.push.apply(providers, __spread(this.compilerProviders)); } // TODO(ocombe): make this work with an Injector directly instead of creating a module for it var CompilerModule = /** @class */ (function () { function CompilerModule() { } return CompilerModule; }()); compileNgModuleDefs(CompilerModule, { providers: providers }); var CompilerModuleFactory = new R3NgModuleFactory(CompilerModule); this._injector = CompilerModuleFactory.create(this.platform.injector).injector; return this._injector; }, enumerable: true, configurable: true }); // get overrides for a specific provider (if any) R3TestBedCompiler.prototype.getSingleProviderOverrides = function (provider) { var token = getProviderToken(provider); return this.providerOverridesByToken.get(token) || null; }; R3TestBedCompiler.prototype.getProviderOverrides = function (providers) { var _this = this; if (!providers || !providers.length || this.providerOverridesByToken.size === 0) return []; // There are two flattening operations here. The inner flatten() operates on the metadata's // providers and applies a mapping function which retrieves overrides for each incoming // provider. The outer flatten() then flattens the produced overrides array. If this is not // done, the array can contain other empty arrays (e.g. `[[], []]`) which leak into the // providers array and contaminate any error messages that might be generated. return flatten(flatten(providers, function (provider) { return _this.getSingleProviderOverrides(provider) || []; })); }; R3TestBedCompiler.prototype.getOverriddenProviders = function (providers) { var _this = this; if (!providers || !providers.length || this.providerOverridesByToken.size === 0) return []; var flattenedProviders = flatten(providers); var overrides = this.getProviderOverrides(flattenedProviders); var overriddenProviders = __spread(flattenedProviders, overrides); var final = []; var seenOverriddenProviders = new Set(); // We iterate through the list of providers in reverse order to make sure provider overrides // take precedence over the values defined in provider list. We also filter out all providers // that have overrides, keeping overridden values only. This is needed, since presence of a // provider with `ngOnDestroy` hook will cause this hook to be registered and invoked later. forEachRight(overriddenProviders, function (provider) { var token = getProviderToken(provider); if (_this.providerOverridesByToken.has(token)) { if (!seenOverriddenProviders.has(token)) { seenOverriddenProviders.add(token); // Treat all overridden providers as `{multi: false}` (even if it's a multi-provider) to // make sure that provided override takes highest precedence and is not combined with // other instances of the same multi provider. final.unshift(__assign(__assign({}, provider), { multi: false })); } } else { final.unshift(provider); } }); return final; }; R3TestBedCompiler.prototype.hasProviderOverrides = function (providers) { return this.getProviderOverrides(providers).length > 0; }; R3TestBedCompiler.prototype.patchDefWithProviderOverrides = function (declaration, field) { var _this = this; var def = declaration[field]; if (def && def.providersResolver) { this.maybeStoreNgDef(field, declaration); var resolver_1 = def.providersResolver; var processProvidersFn_1 = function (providers) { return _this.getOverriddenProviders(providers); }; this.storeFieldOfDefOnType(declaration, field, 'providersResolver'); def.providersResolver = function (ngDef) { return resolver_1(ngDef, processProvidersFn_1); }; } }; return R3TestBedCompiler; }()); export { R3TestBedCompiler }; function initResolvers() { return { module: new NgModuleResolver(), component: new ComponentResolver(), directive: new DirectiveResolver(), pipe: new PipeResolver() }; } function hasNgModuleDef(value) { return value.hasOwnProperty('ɵmod'); } function maybeUnwrapFn(maybeFn) { return maybeFn instanceof Function ? maybeFn() : maybeFn; } function flatten(values, mapFn) { var out = []; values.forEach(function (value) { if (Array.isArray(value)) { out.push.apply(out, __spread(flatten(value, mapFn))); } else { out.push(mapFn ? mapFn(value) : value); } }); return out; } function getProviderField(provider, field) { return provider && typeof provider === 'object' && provider[field]; } function getProviderToken(provider) { return getProviderField(provider, 'provide') || provider; } function isModuleWithProviders(value) { return value.hasOwnProperty('ngModule'); } function forEachRight(values, fn) { for (var idx = values.length - 1; idx >= 0; idx--) { fn(values[idx], idx); } } function invalidTypeError(name, expectedType) { return new Error(name + " class doesn't have @" + expectedType + " decorator or is missing metadata."); } var R3TestCompiler = /** @class */ (function () { function R3TestCompiler(testBed) { this.testBed = testBed; } R3TestCompiler.prototype.compileModuleSync = function (moduleType) { this.testBed._compileNgModuleSync(moduleType); return new R3NgModuleFactory(moduleType); }; R3TestCompiler.prototype.compileModuleAsync = function (moduleType) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.testBed._compileNgModuleAsync(moduleType)]; case 1: _a.sent(); return [2 /*return*/, new R3NgModuleFactory(moduleType)]; } }); }); }; R3TestCompiler.prototype.compileModuleAndAllComponentsSync = function (moduleType) { var ngModuleFactory = this.compileModuleSync(moduleType); var componentFactories = this.testBed._getComponentFactories(moduleType); return new ModuleWithComponentFactories(ngModuleFactory, componentFactories); }; R3TestCompiler.prototype.compileModuleAndAllComponentsAsync = function (moduleType) { return __awaiter(this, void 0, void 0, function () { var ngModuleFactory, componentFactories; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, this.compileModuleAsync(moduleType)]; case 1: ngModuleFactory = _a.sent(); componentFactories = this.testBed._getComponentFactories(moduleType); return [2 /*return*/, new ModuleWithComponentFactories(ngModuleFactory, componentFactories)]; } }); }); }; R3TestCompiler.prototype.clearCache = function () { }; R3TestCompiler.prototype.clearCacheFor = function (type) { }; R3TestCompiler.prototype.getModuleId = function (moduleType) { var meta = this.testBed._getModuleResolver().resolve(moduleType); return meta && meta.id || undefined; }; return R3TestCompiler; }()); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicjNfdGVzdF9iZWRfY29tcGlsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb3JlL3Rlc3Rpbmcvc3JjL3IzX3Rlc3RfYmVkX2NvbXBpbGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7QUFFSCxPQUFPLEVBQUMsY0FBYyxFQUFDLE1BQU0sbUJBQW1CLENBQUM7QUFDakQsT0FBTyxFQUFDLHFCQUFxQixFQUFFLFFBQVEsRUFBRSxnQkFBZ0IsRUFBZ0QsU0FBUyxFQUFFLDRCQUE0QixFQUFrRCxNQUFNLEVBQXFDLGlCQUFpQixJQUFJLGdCQUFnQixFQUFFLGlCQUFpQixJQUFJLGdCQUFnQixFQUFFLG9CQUFvQixJQUFJLG1CQUFtQixFQUFFLFlBQVksSUFBSSxXQUFXLEVBQUUsa0JBQWtCLElBQUksaUJBQWlCLEVBQWlDLGlCQUFpQixJQUFJLGdCQUFnQixFQUFFLFlBQVksSUFBSSxXQUFXLEVBQUUsV0FBVyxJQUFJLFVBQVUsRUFBRSxXQUFXLElBQUksVUFBVSxF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