@angular/core 12.1.0-next.3 → 12.1.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/bundles/core-testing.umd.js +229 -101
- package/bundles/core-testing.umd.js.map +1 -1
- package/bundles/core.umd.js +65 -28
- package/bundles/core.umd.js.map +1 -1
- package/core.d.ts +269 -19
- package/core.metadata.json +1 -1
- package/esm2015/src/application_ref.js +29 -8
- package/esm2015/src/change_detection/differs/iterable_differs.js +1 -1
- package/esm2015/src/debug/debug_node.js +1 -1
- package/esm2015/src/di/injectable.js +1 -1
- package/esm2015/src/di/injector_marker.js +1 -1
- package/esm2015/src/linker/component_factory_resolver.js +4 -1
- package/esm2015/src/linker/element_ref.js +1 -1
- package/esm2015/src/linker/query_list.js +2 -1
- package/esm2015/src/metadata/di.js +1 -1
- package/esm2015/src/metadata/do_boostrap.js +1 -1
- package/esm2015/src/metadata/ng_module.js +1 -1
- package/esm2015/src/metadata/schema.js +5 -1
- package/esm2015/src/render3/definition.js +16 -16
- package/esm2015/src/render3/node_assert.js +1 -1
- package/esm2015/src/util/assert.js +1 -1
- package/esm2015/src/util/decorators.js +1 -1
- package/esm2015/src/util/dom.js +1 -1
- package/esm2015/src/version.js +1 -1
- package/esm2015/src/view/util.js +3 -1
- package/esm2015/testing/src/r3_test_bed.js +84 -7
- package/esm2015/testing/src/test_bed.js +103 -42
- package/esm2015/testing/src/test_bed_common.js +7 -1
- package/esm2015/testing/src/test_hooks.js +45 -0
- package/esm2015/testing/src/testing.js +3 -3
- package/esm2015/testing/src/testing_internal.js +1 -182
- package/fesm2015/core.js +55 -24
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/testing.js +206 -77
- package/fesm2015/testing.js.map +1 -1
- package/package.json +2 -2
- package/schematics/migrations/can-activate-with-redirect-to/util.js +1 -1
- package/schematics/migrations/can-activate-with-redirect-to/util.mjs +1 -1
- package/schematics/migrations/initial-navigation/collector.js +3 -2
- package/schematics/migrations/initial-navigation/collector.mjs +3 -2
- package/schematics/migrations/navigation-extras-omissions/util.js +2 -3
- package/schematics/migrations/navigation-extras-omissions/util.mjs +2 -3
- package/schematics/migrations/relative-link-resolution/collector.js +3 -2
- package/schematics/migrations/relative-link-resolution/collector.mjs +3 -2
- package/schematics/migrations/relative-link-resolution/update_recorder.js +1 -1
- package/schematics/migrations/relative-link-resolution/update_recorder.mjs +1 -1
- package/schematics/migrations/static-queries/strategies/usage_strategy/declaration_usage_visitor.js +2 -2
- package/schematics/migrations/static-queries/strategies/usage_strategy/declaration_usage_visitor.mjs +2 -2
- package/schematics/migrations/xhr-factory/index.js +1 -1
- package/schematics/migrations/xhr-factory/index.mjs +1 -1
- package/schematics/utils/typescript/imports.js +2 -2
- package/schematics/utils/typescript/imports.mjs +2 -2
- package/src/r3_symbols.d.ts +4 -1
- package/testing/testing.d.ts +63 -10
- package/testing/testing.metadata.json +1 -1
- package/testing.d.ts +1 -1
- package/esm2015/testing/src/async_test_completer.js +0 -28
- package/esm2015/testing/src/before_each.js +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.1.0
|
|
2
|
+
* @license Angular v12.1.0
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -647,10 +647,16 @@
|
|
|
647
647
|
r[k] = a[j];
|
|
648
648
|
return r;
|
|
649
649
|
}
|
|
650
|
-
function __spreadArray(to, from) {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
650
|
+
function __spreadArray(to, from, pack) {
|
|
651
|
+
if (pack || arguments.length === 2)
|
|
652
|
+
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
653
|
+
if (ar || !(i in from)) {
|
|
654
|
+
if (!ar)
|
|
655
|
+
ar = Array.prototype.slice.call(from, 0, i);
|
|
656
|
+
ar[i] = from[i];
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return to.concat(ar || from);
|
|
654
660
|
}
|
|
655
661
|
function __await(v) {
|
|
656
662
|
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
@@ -733,40 +739,6 @@
|
|
|
733
739
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
734
740
|
}
|
|
735
741
|
|
|
736
|
-
/**
|
|
737
|
-
* @license
|
|
738
|
-
* Copyright Google LLC All Rights Reserved.
|
|
739
|
-
*
|
|
740
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
741
|
-
* found in the LICENSE file at https://angular.io/license
|
|
742
|
-
*/
|
|
743
|
-
/**
|
|
744
|
-
* Injectable completer that allows signaling completion of an asynchronous test. Used internally.
|
|
745
|
-
*/
|
|
746
|
-
var AsyncTestCompleter = /** @class */ (function () {
|
|
747
|
-
function AsyncTestCompleter() {
|
|
748
|
-
var _this = this;
|
|
749
|
-
this._promise = new Promise(function (res, rej) {
|
|
750
|
-
_this._resolve = res;
|
|
751
|
-
_this._reject = rej;
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
AsyncTestCompleter.prototype.done = function (value) {
|
|
755
|
-
this._resolve(value);
|
|
756
|
-
};
|
|
757
|
-
AsyncTestCompleter.prototype.fail = function (error, stackTrace) {
|
|
758
|
-
this._reject(error);
|
|
759
|
-
};
|
|
760
|
-
Object.defineProperty(AsyncTestCompleter.prototype, "promise", {
|
|
761
|
-
get: function () {
|
|
762
|
-
return this._promise;
|
|
763
|
-
},
|
|
764
|
-
enumerable: false,
|
|
765
|
-
configurable: true
|
|
766
|
-
});
|
|
767
|
-
return AsyncTestCompleter;
|
|
768
|
-
}());
|
|
769
|
-
|
|
770
742
|
/**
|
|
771
743
|
* @license
|
|
772
744
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1962,6 +1934,11 @@
|
|
|
1962
1934
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1963
1935
|
* found in the LICENSE file at https://angular.io/license
|
|
1964
1936
|
*/
|
|
1937
|
+
/**
|
|
1938
|
+
* Whether test modules should be torn down by default.
|
|
1939
|
+
* Currently disabled for backwards-compatibility reasons.
|
|
1940
|
+
*/
|
|
1941
|
+
var TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = false;
|
|
1965
1942
|
/**
|
|
1966
1943
|
* An abstract class for inserting the root test component element in a platform independent way.
|
|
1967
1944
|
*
|
|
@@ -1971,6 +1948,7 @@
|
|
|
1971
1948
|
function TestComponentRenderer() {
|
|
1972
1949
|
}
|
|
1973
1950
|
TestComponentRenderer.prototype.insertRootElement = function (rootElementId) { };
|
|
1951
|
+
TestComponentRenderer.prototype.removeAllRootElements = function () { };
|
|
1974
1952
|
return TestComponentRenderer;
|
|
1975
1953
|
}());
|
|
1976
1954
|
/**
|
|
@@ -2023,9 +2001,9 @@
|
|
|
2023
2001
|
*
|
|
2024
2002
|
* @publicApi
|
|
2025
2003
|
*/
|
|
2026
|
-
TestBedRender3.initTestEnvironment = function (ngModule, platform,
|
|
2004
|
+
TestBedRender3.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2027
2005
|
var testBed = _getTestBedRender3();
|
|
2028
|
-
testBed.initTestEnvironment(ngModule, platform,
|
|
2006
|
+
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
|
|
2029
2007
|
return testBed;
|
|
2030
2008
|
};
|
|
2031
2009
|
/**
|
|
@@ -2106,6 +2084,12 @@
|
|
|
2106
2084
|
_getTestBedRender3().resetTestingModule();
|
|
2107
2085
|
return TestBedRender3;
|
|
2108
2086
|
};
|
|
2087
|
+
TestBedRender3.shouldTearDownTestingModule = function () {
|
|
2088
|
+
return _getTestBedRender3().shouldTearDownTestingModule();
|
|
2089
|
+
};
|
|
2090
|
+
TestBedRender3.tearDownTestingModule = function () {
|
|
2091
|
+
_getTestBedRender3().tearDownTestingModule();
|
|
2092
|
+
};
|
|
2109
2093
|
/**
|
|
2110
2094
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
2111
2095
|
* angular module. These are common to every test in the suite.
|
|
@@ -2119,10 +2103,14 @@
|
|
|
2119
2103
|
*
|
|
2120
2104
|
* @publicApi
|
|
2121
2105
|
*/
|
|
2122
|
-
TestBedRender3.prototype.initTestEnvironment = function (ngModule, platform,
|
|
2106
|
+
TestBedRender3.prototype.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2123
2107
|
if (this.platform || this.ngModule) {
|
|
2124
2108
|
throw new Error('Cannot set base providers because it has already been called');
|
|
2125
2109
|
}
|
|
2110
|
+
// If `summariesOrOptions` is a function, it means that it's
|
|
2111
|
+
// an AOT summaries factory which Ivy doesn't support.
|
|
2112
|
+
TestBedRender3._environmentTeardownOptions =
|
|
2113
|
+
typeof summariesOrOptions === 'function' ? undefined : summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.teardown;
|
|
2126
2114
|
this.platform = platform;
|
|
2127
2115
|
this.ngModule = ngModule;
|
|
2128
2116
|
this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
|
|
@@ -2137,6 +2125,7 @@
|
|
|
2137
2125
|
this._compiler = null;
|
|
2138
2126
|
this.platform = null;
|
|
2139
2127
|
this.ngModule = null;
|
|
2128
|
+
TestBedRender3._environmentTeardownOptions = undefined;
|
|
2140
2129
|
};
|
|
2141
2130
|
TestBedRender3.prototype.resetTestingModule = function () {
|
|
2142
2131
|
this.checkGlobalCompilationFinished();
|
|
@@ -2145,8 +2134,23 @@
|
|
|
2145
2134
|
this.compiler.restoreOriginalState();
|
|
2146
2135
|
}
|
|
2147
2136
|
this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
|
|
2148
|
-
|
|
2149
|
-
|
|
2137
|
+
// We have to chain a couple of try/finally blocks, because each step can
|
|
2138
|
+
// throw errors and we don't want it to interrupt the next step and we also
|
|
2139
|
+
// want an error to be thrown at the end.
|
|
2140
|
+
try {
|
|
2141
|
+
this.destroyActiveFixtures();
|
|
2142
|
+
}
|
|
2143
|
+
finally {
|
|
2144
|
+
try {
|
|
2145
|
+
if (this.shouldTearDownTestingModule()) {
|
|
2146
|
+
this.tearDownTestingModule();
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
finally {
|
|
2150
|
+
this._testModuleRef = null;
|
|
2151
|
+
this._instanceTeardownOptions = undefined;
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2150
2154
|
};
|
|
2151
2155
|
TestBedRender3.prototype.configureCompiler = function (config) {
|
|
2152
2156
|
if (config.useJit != null) {
|
|
@@ -2158,6 +2162,9 @@
|
|
|
2158
2162
|
};
|
|
2159
2163
|
TestBedRender3.prototype.configureTestingModule = function (moduleDef) {
|
|
2160
2164
|
this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
|
|
2165
|
+
// Always re-assign the teardown options, even if they're undefined.
|
|
2166
|
+
// This ensures that we don't carry the options between tests.
|
|
2167
|
+
this._instanceTeardownOptions = moduleDef.teardown;
|
|
2161
2168
|
this.compiler.configureTestingModule(moduleDef);
|
|
2162
2169
|
};
|
|
2163
2170
|
TestBedRender3.prototype.compileComponents = function () {
|
|
@@ -2288,11 +2295,13 @@
|
|
|
2288
2295
|
this._globalCompilationChecked = true;
|
|
2289
2296
|
};
|
|
2290
2297
|
TestBedRender3.prototype.destroyActiveFixtures = function () {
|
|
2298
|
+
var errorCount = 0;
|
|
2291
2299
|
this._activeFixtures.forEach(function (fixture) {
|
|
2292
2300
|
try {
|
|
2293
2301
|
fixture.destroy();
|
|
2294
2302
|
}
|
|
2295
2303
|
catch (e) {
|
|
2304
|
+
errorCount++;
|
|
2296
2305
|
console.error('Error during cleanup of component', {
|
|
2297
2306
|
component: fixture.componentInstance,
|
|
2298
2307
|
stacktrace: e,
|
|
@@ -2300,6 +2309,52 @@
|
|
|
2300
2309
|
}
|
|
2301
2310
|
});
|
|
2302
2311
|
this._activeFixtures = [];
|
|
2312
|
+
if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
|
|
2313
|
+
throw Error(errorCount + " " + (errorCount === 1 ? 'component' : 'components') + " " +
|
|
2314
|
+
"threw errors during cleanup");
|
|
2315
|
+
}
|
|
2316
|
+
};
|
|
2317
|
+
TestBedRender3.prototype.shouldRethrowTeardownErrors = function () {
|
|
2318
|
+
var _a, _b;
|
|
2319
|
+
var instanceOptions = this._instanceTeardownOptions;
|
|
2320
|
+
var environmentOptions = TestBedRender3._environmentTeardownOptions;
|
|
2321
|
+
// If the new teardown behavior hasn't been configured, preserve the old behavior.
|
|
2322
|
+
if (!instanceOptions && !environmentOptions) {
|
|
2323
|
+
return false;
|
|
2324
|
+
}
|
|
2325
|
+
// Otherwise use the configured behavior or default to rethrowing.
|
|
2326
|
+
return (_b = (_a = instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.rethrowErrors) !== null && _a !== void 0 ? _a : environmentOptions === null || environmentOptions === void 0 ? void 0 : environmentOptions.rethrowErrors) !== null && _b !== void 0 ? _b : true;
|
|
2327
|
+
};
|
|
2328
|
+
TestBedRender3.prototype.shouldTearDownTestingModule = function () {
|
|
2329
|
+
var _a, _b, _c, _d;
|
|
2330
|
+
return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedRender3._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
2331
|
+
};
|
|
2332
|
+
TestBedRender3.prototype.tearDownTestingModule = function () {
|
|
2333
|
+
var _a;
|
|
2334
|
+
// If the module ref has already been destroyed, we won't be able to get a test renderer.
|
|
2335
|
+
if (this._testModuleRef === null) {
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2338
|
+
// Resolve the renderer ahead of time, because we want to remove the root elements as the very
|
|
2339
|
+
// last step, but the injector will be destroyed as a part of the module ref destruction.
|
|
2340
|
+
var testRenderer = this.inject(TestComponentRenderer);
|
|
2341
|
+
try {
|
|
2342
|
+
this._testModuleRef.destroy();
|
|
2343
|
+
}
|
|
2344
|
+
catch (e) {
|
|
2345
|
+
if (this.shouldRethrowTeardownErrors()) {
|
|
2346
|
+
throw e;
|
|
2347
|
+
}
|
|
2348
|
+
else {
|
|
2349
|
+
console.error('Error during cleanup of a testing module', {
|
|
2350
|
+
component: this._testModuleRef.instance,
|
|
2351
|
+
stacktrace: e,
|
|
2352
|
+
});
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
finally {
|
|
2356
|
+
(_a = testRenderer.removeAllRootElements) === null || _a === void 0 ? void 0 : _a.call(testRenderer);
|
|
2357
|
+
}
|
|
2303
2358
|
};
|
|
2304
2359
|
return TestBedRender3;
|
|
2305
2360
|
}());
|
|
@@ -2424,9 +2479,9 @@
|
|
|
2424
2479
|
* Test modules and platforms for individual platforms are available from
|
|
2425
2480
|
* '@angular/<platform_name>/testing'.
|
|
2426
2481
|
*/
|
|
2427
|
-
TestBedViewEngine.initTestEnvironment = function (ngModule, platform,
|
|
2482
|
+
TestBedViewEngine.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2428
2483
|
var testBed = _getTestBedViewEngine();
|
|
2429
|
-
testBed.initTestEnvironment(ngModule, platform,
|
|
2484
|
+
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
|
|
2430
2485
|
return testBed;
|
|
2431
2486
|
};
|
|
2432
2487
|
/**
|
|
@@ -2509,6 +2564,12 @@
|
|
|
2509
2564
|
TestBedViewEngine.createComponent = function (component) {
|
|
2510
2565
|
return _getTestBedViewEngine().createComponent(component);
|
|
2511
2566
|
};
|
|
2567
|
+
TestBedViewEngine.shouldTearDownTestingModule = function () {
|
|
2568
|
+
return _getTestBedViewEngine().shouldTearDownTestingModule();
|
|
2569
|
+
};
|
|
2570
|
+
TestBedViewEngine.tearDownTestingModule = function () {
|
|
2571
|
+
_getTestBedViewEngine().tearDownTestingModule();
|
|
2572
|
+
};
|
|
2512
2573
|
/**
|
|
2513
2574
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
2514
2575
|
* angular module. These are common to every test in the suite.
|
|
@@ -2520,14 +2581,19 @@
|
|
|
2520
2581
|
* Test modules and platforms for individual platforms are available from
|
|
2521
2582
|
* '@angular/<platform_name>/testing'.
|
|
2522
2583
|
*/
|
|
2523
|
-
TestBedViewEngine.prototype.initTestEnvironment = function (ngModule, platform,
|
|
2584
|
+
TestBedViewEngine.prototype.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2524
2585
|
if (this.platform || this.ngModule) {
|
|
2525
2586
|
throw new Error('Cannot set base providers because it has already been called');
|
|
2526
2587
|
}
|
|
2527
2588
|
this.platform = platform;
|
|
2528
2589
|
this.ngModule = ngModule;
|
|
2529
|
-
if (
|
|
2530
|
-
this._testEnvAotSummaries =
|
|
2590
|
+
if (typeof summariesOrOptions === 'function') {
|
|
2591
|
+
this._testEnvAotSummaries = summariesOrOptions;
|
|
2592
|
+
TestBedViewEngine._environmentTeardownOptions = undefined;
|
|
2593
|
+
}
|
|
2594
|
+
else {
|
|
2595
|
+
this._testEnvAotSummaries = (summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.aotSummaries) || (function () { return []; });
|
|
2596
|
+
TestBedViewEngine._environmentTeardownOptions = summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.teardown;
|
|
2531
2597
|
}
|
|
2532
2598
|
};
|
|
2533
2599
|
/**
|
|
@@ -2538,6 +2604,7 @@
|
|
|
2538
2604
|
this.platform = null;
|
|
2539
2605
|
this.ngModule = null;
|
|
2540
2606
|
this._testEnvAotSummaries = function () { return []; };
|
|
2607
|
+
TestBedViewEngine._environmentTeardownOptions = undefined;
|
|
2541
2608
|
};
|
|
2542
2609
|
TestBedViewEngine.prototype.resetTestingModule = function () {
|
|
2543
2610
|
core.ɵclearOverrides();
|
|
@@ -2550,49 +2617,56 @@
|
|
|
2550
2617
|
this._pipeOverrides = [];
|
|
2551
2618
|
this._isRoot = true;
|
|
2552
2619
|
this._rootProviderOverrides = [];
|
|
2553
|
-
this._moduleRef = null;
|
|
2554
2620
|
this._moduleFactory = null;
|
|
2555
2621
|
this._compilerOptions = [];
|
|
2556
2622
|
this._providers = [];
|
|
2557
2623
|
this._declarations = [];
|
|
2558
2624
|
this._imports = [];
|
|
2559
2625
|
this._schemas = [];
|
|
2560
|
-
|
|
2561
|
-
|
|
2626
|
+
// We have to chain a couple of try/finally blocks, because each step can
|
|
2627
|
+
// throw errors and we don't want it to interrupt the next step and we also
|
|
2628
|
+
// want an error to be thrown at the end.
|
|
2629
|
+
try {
|
|
2630
|
+
this.destroyActiveFixtures();
|
|
2631
|
+
}
|
|
2632
|
+
finally {
|
|
2562
2633
|
try {
|
|
2563
|
-
|
|
2634
|
+
if (this.shouldTearDownTestingModule()) {
|
|
2635
|
+
this.tearDownTestingModule();
|
|
2636
|
+
}
|
|
2564
2637
|
}
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
});
|
|
2638
|
+
finally {
|
|
2639
|
+
this._moduleRef = null;
|
|
2640
|
+
this._instanceTeardownOptions = undefined;
|
|
2641
|
+
this._instantiated = false;
|
|
2570
2642
|
}
|
|
2571
|
-
}
|
|
2572
|
-
this._activeFixtures = [];
|
|
2643
|
+
}
|
|
2573
2644
|
};
|
|
2574
2645
|
TestBedViewEngine.prototype.configureCompiler = function (config) {
|
|
2575
2646
|
this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
|
|
2576
2647
|
this._compilerOptions.push(config);
|
|
2577
2648
|
};
|
|
2578
2649
|
TestBedViewEngine.prototype.configureTestingModule = function (moduleDef) {
|
|
2579
|
-
var
|
|
2650
|
+
var _f, _g, _h, _j;
|
|
2580
2651
|
this._assertNotInstantiated('TestBed.configureTestingModule', 'configure the test module');
|
|
2581
2652
|
if (moduleDef.providers) {
|
|
2582
|
-
(
|
|
2653
|
+
(_f = this._providers).push.apply(_f, __spreadArray([], __read(moduleDef.providers)));
|
|
2583
2654
|
}
|
|
2584
2655
|
if (moduleDef.declarations) {
|
|
2585
|
-
(
|
|
2656
|
+
(_g = this._declarations).push.apply(_g, __spreadArray([], __read(moduleDef.declarations)));
|
|
2586
2657
|
}
|
|
2587
2658
|
if (moduleDef.imports) {
|
|
2588
|
-
(
|
|
2659
|
+
(_h = this._imports).push.apply(_h, __spreadArray([], __read(moduleDef.imports)));
|
|
2589
2660
|
}
|
|
2590
2661
|
if (moduleDef.schemas) {
|
|
2591
|
-
(
|
|
2662
|
+
(_j = this._schemas).push.apply(_j, __spreadArray([], __read(moduleDef.schemas)));
|
|
2592
2663
|
}
|
|
2593
2664
|
if (moduleDef.aotSummaries) {
|
|
2594
2665
|
this._aotSummaries.push(moduleDef.aotSummaries);
|
|
2595
2666
|
}
|
|
2667
|
+
// Always re-assign the teardown options, even if they're undefined.
|
|
2668
|
+
// This ensures that we don't carry the options between tests.
|
|
2669
|
+
this._instanceTeardownOptions = moduleDef.teardown;
|
|
2596
2670
|
};
|
|
2597
2671
|
TestBedViewEngine.prototype.compileComponents = function () {
|
|
2598
2672
|
var _this = this;
|
|
@@ -2606,7 +2680,7 @@
|
|
|
2606
2680
|
});
|
|
2607
2681
|
};
|
|
2608
2682
|
TestBedViewEngine.prototype._initIfNeeded = function () {
|
|
2609
|
-
var e_1,
|
|
2683
|
+
var e_1, _f;
|
|
2610
2684
|
if (this._instantiated) {
|
|
2611
2685
|
return;
|
|
2612
2686
|
}
|
|
@@ -2628,8 +2702,8 @@
|
|
|
2628
2702
|
}
|
|
2629
2703
|
}
|
|
2630
2704
|
try {
|
|
2631
|
-
for (var
|
|
2632
|
-
var
|
|
2705
|
+
for (var _g = __values(this._templateOverrides), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2706
|
+
var _j = _h.value, component = _j.component, templateOf = _j.templateOf;
|
|
2633
2707
|
var compFactory = this._compiler.getComponentFactory(templateOf);
|
|
2634
2708
|
core.ɵoverrideComponentView(component, compFactory);
|
|
2635
2709
|
}
|
|
@@ -2637,7 +2711,7 @@
|
|
|
2637
2711
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2638
2712
|
finally {
|
|
2639
2713
|
try {
|
|
2640
|
-
if (
|
|
2714
|
+
if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
|
|
2641
2715
|
}
|
|
2642
2716
|
finally { if (e_1) throw e_1.error; }
|
|
2643
2717
|
}
|
|
@@ -2655,7 +2729,7 @@
|
|
|
2655
2729
|
this._instantiated = true;
|
|
2656
2730
|
};
|
|
2657
2731
|
TestBedViewEngine.prototype._createCompilerAndModule = function () {
|
|
2658
|
-
var e_2,
|
|
2732
|
+
var e_2, _f;
|
|
2659
2733
|
var _this = this;
|
|
2660
2734
|
var providers = this._providers.concat([{ provide: TestBed, useValue: this }]);
|
|
2661
2735
|
var declarations = __spreadArray(__spreadArray([], __read(this._declarations)), __read(this._templateOverrides.map(function (entry) { return entry.templateOf; })));
|
|
@@ -2689,15 +2763,15 @@
|
|
|
2689
2763
|
var compilerFactory = this.platform.injector.get(TestingCompilerFactory);
|
|
2690
2764
|
this._compiler = compilerFactory.createTestingCompiler(this._compilerOptions);
|
|
2691
2765
|
try {
|
|
2692
|
-
for (var
|
|
2693
|
-
var summary =
|
|
2766
|
+
for (var _g = __values(__spreadArray([this._testEnvAotSummaries], __read(this._aotSummaries))), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
2767
|
+
var summary = _h.value;
|
|
2694
2768
|
this._compiler.loadAotSummaries(summary);
|
|
2695
2769
|
}
|
|
2696
2770
|
}
|
|
2697
2771
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2698
2772
|
finally {
|
|
2699
2773
|
try {
|
|
2700
|
-
if (
|
|
2774
|
+
if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
|
|
2701
2775
|
}
|
|
2702
2776
|
finally { if (e_2) throw e_2.error; }
|
|
2703
2777
|
}
|
|
@@ -2836,6 +2910,68 @@
|
|
|
2836
2910
|
this._activeFixtures.push(fixture);
|
|
2837
2911
|
return fixture;
|
|
2838
2912
|
};
|
|
2913
|
+
TestBedViewEngine.prototype.destroyActiveFixtures = function () {
|
|
2914
|
+
var errorCount = 0;
|
|
2915
|
+
this._activeFixtures.forEach(function (fixture) {
|
|
2916
|
+
try {
|
|
2917
|
+
fixture.destroy();
|
|
2918
|
+
}
|
|
2919
|
+
catch (e) {
|
|
2920
|
+
errorCount++;
|
|
2921
|
+
console.error('Error during cleanup of component', {
|
|
2922
|
+
component: fixture.componentInstance,
|
|
2923
|
+
stacktrace: e,
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
this._activeFixtures = [];
|
|
2928
|
+
if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
|
|
2929
|
+
throw Error(errorCount + " " + (errorCount === 1 ? 'component' : 'components') + " " +
|
|
2930
|
+
"threw errors during cleanup");
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
TestBedViewEngine.prototype.shouldRethrowTeardownErrors = function () {
|
|
2934
|
+
var _a, _b;
|
|
2935
|
+
var instanceOptions = this._instanceTeardownOptions;
|
|
2936
|
+
var environmentOptions = TestBedViewEngine._environmentTeardownOptions;
|
|
2937
|
+
// If the new teardown behavior hasn't been configured, preserve the old behavior.
|
|
2938
|
+
if (!instanceOptions && !environmentOptions) {
|
|
2939
|
+
return false;
|
|
2940
|
+
}
|
|
2941
|
+
// Otherwise use the configured behavior or default to rethrowing.
|
|
2942
|
+
return (_b = (_a = instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.rethrowErrors) !== null && _a !== void 0 ? _a : environmentOptions === null || environmentOptions === void 0 ? void 0 : environmentOptions.rethrowErrors) !== null && _b !== void 0 ? _b : true;
|
|
2943
|
+
};
|
|
2944
|
+
TestBedViewEngine.prototype.shouldTearDownTestingModule = function () {
|
|
2945
|
+
var _a, _b, _c, _d;
|
|
2946
|
+
return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedViewEngine._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
|
|
2947
|
+
};
|
|
2948
|
+
TestBedViewEngine.prototype.tearDownTestingModule = function () {
|
|
2949
|
+
var _a, _b, _c, _d, _e;
|
|
2950
|
+
// If the module ref has already been destroyed, we won't be able to get a test renderer.
|
|
2951
|
+
if (this._moduleRef === null) {
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
// Resolve the renderer ahead of time, because we want to remove the root elements as the very
|
|
2955
|
+
// last step, but the injector will be destroyed as a part of the module ref destruction.
|
|
2956
|
+
var testRenderer = this.inject(TestComponentRenderer);
|
|
2957
|
+
try {
|
|
2958
|
+
this._moduleRef.destroy();
|
|
2959
|
+
}
|
|
2960
|
+
catch (e) {
|
|
2961
|
+
if ((_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.rethrowErrors) !== null && _b !== void 0 ? _b : (_c = TestBedViewEngine._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.rethrowErrors) !== null && _d !== void 0 ? _d : true) {
|
|
2962
|
+
throw e;
|
|
2963
|
+
}
|
|
2964
|
+
else {
|
|
2965
|
+
console.error('Error during cleanup of a testing module', {
|
|
2966
|
+
component: this._moduleRef.instance,
|
|
2967
|
+
stacktrace: e,
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
finally {
|
|
2972
|
+
(_e = testRenderer === null || testRenderer === void 0 ? void 0 : testRenderer.removeAllRootElements) === null || _e === void 0 ? void 0 : _e.call(testRenderer);
|
|
2973
|
+
}
|
|
2974
|
+
};
|
|
2839
2975
|
return TestBedViewEngine;
|
|
2840
2976
|
}());
|
|
2841
2977
|
/**
|
|
@@ -2880,34 +3016,14 @@
|
|
|
2880
3016
|
* })
|
|
2881
3017
|
* ```
|
|
2882
3018
|
*
|
|
2883
|
-
* Notes:
|
|
2884
|
-
* - inject is currently a function because of some Traceur limitation the syntax should
|
|
2885
|
-
* eventually
|
|
2886
|
-
* becomes `it('...', @Inject (object: AClass, async: AsyncTestCompleter) => { ... });`
|
|
2887
|
-
*
|
|
2888
3019
|
* @publicApi
|
|
2889
3020
|
*/
|
|
2890
3021
|
function inject(tokens, fn) {
|
|
2891
3022
|
var testBed = getTestBed();
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
return
|
|
2895
|
-
|
|
2896
|
-
// Return an async test method that returns a Promise if AsyncTestCompleter is one of
|
|
2897
|
-
// the injected tokens.
|
|
2898
|
-
return testBed.compileComponents().then(function () {
|
|
2899
|
-
var completer = testBed.inject(AsyncTestCompleter);
|
|
2900
|
-
testBed.execute(tokens, fn, _this);
|
|
2901
|
-
return completer.promise;
|
|
2902
|
-
});
|
|
2903
|
-
};
|
|
2904
|
-
}
|
|
2905
|
-
else {
|
|
2906
|
-
// Not using an arrow function to preserve context passed from call site
|
|
2907
|
-
return function () {
|
|
2908
|
-
return testBed.execute(tokens, fn, this);
|
|
2909
|
-
};
|
|
2910
|
-
}
|
|
3023
|
+
// Not using an arrow function to preserve context passed from call site
|
|
3024
|
+
return function () {
|
|
3025
|
+
return testBed.execute(tokens, fn, this);
|
|
3026
|
+
};
|
|
2911
3027
|
}
|
|
2912
3028
|
/**
|
|
2913
3029
|
* @publicApi
|
|
@@ -2956,10 +3072,22 @@
|
|
|
2956
3072
|
var _global = (typeof window === 'undefined' ? global : window);
|
|
2957
3073
|
// Reset the test providers and the fake async zone before each test.
|
|
2958
3074
|
if (_global.beforeEach) {
|
|
2959
|
-
_global.beforeEach(
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
3075
|
+
_global.beforeEach(getCleanupHook(false));
|
|
3076
|
+
}
|
|
3077
|
+
// We provide both a `beforeEach` and `afterEach`, because the updated behavior for
|
|
3078
|
+
// tearing down the module is supposed to run after the test so that we can associate
|
|
3079
|
+
// teardown errors with the correct test.
|
|
3080
|
+
if (_global.afterEach) {
|
|
3081
|
+
_global.afterEach(getCleanupHook(true));
|
|
3082
|
+
}
|
|
3083
|
+
function getCleanupHook(expectedTeardownValue) {
|
|
3084
|
+
return function () {
|
|
3085
|
+
if (TestBed.shouldTearDownTestingModule() ===
|
|
3086
|
+
expectedTeardownValue) {
|
|
3087
|
+
TestBed.resetTestingModule();
|
|
3088
|
+
resetFakeAsyncZone();
|
|
3089
|
+
}
|
|
3090
|
+
};
|
|
2963
3091
|
}
|
|
2964
3092
|
/**
|
|
2965
3093
|
* This API should be removed. But doing so seems to break `google3` and so it requires a bit of
|