@angular/core 12.1.0-next.6 → 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 +225 -43
- package/bundles/core-testing.umd.js.map +1 -1
- package/bundles/core.umd.js +40 -13
- package/bundles/core.umd.js.map +1 -1
- package/core.d.ts +32 -8
- package/core.metadata.json +1 -1
- package/esm2015/src/application_ref.js +29 -8
- package/esm2015/src/metadata/do_boostrap.js +1 -1
- package/esm2015/src/version.js +1 -1
- package/esm2015/testing/src/r3_test_bed.js +84 -7
- package/esm2015/testing/src/test_bed.js +99 -18
- 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/fesm2015/core.js +30 -9
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/testing.js +202 -26
- package/fesm2015/testing.js.map +1 -1
- package/package.json +1 -1
- package/src/r3_symbols.d.ts +1 -1
- package/testing/testing.d.ts +63 -5
- package/testing/testing.metadata.json +1 -1
- package/testing.d.ts +1 -1
- 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);
|
|
@@ -1928,6 +1934,11 @@
|
|
|
1928
1934
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1929
1935
|
* found in the LICENSE file at https://angular.io/license
|
|
1930
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;
|
|
1931
1942
|
/**
|
|
1932
1943
|
* An abstract class for inserting the root test component element in a platform independent way.
|
|
1933
1944
|
*
|
|
@@ -1937,6 +1948,7 @@
|
|
|
1937
1948
|
function TestComponentRenderer() {
|
|
1938
1949
|
}
|
|
1939
1950
|
TestComponentRenderer.prototype.insertRootElement = function (rootElementId) { };
|
|
1951
|
+
TestComponentRenderer.prototype.removeAllRootElements = function () { };
|
|
1940
1952
|
return TestComponentRenderer;
|
|
1941
1953
|
}());
|
|
1942
1954
|
/**
|
|
@@ -1989,9 +2001,9 @@
|
|
|
1989
2001
|
*
|
|
1990
2002
|
* @publicApi
|
|
1991
2003
|
*/
|
|
1992
|
-
TestBedRender3.initTestEnvironment = function (ngModule, platform,
|
|
2004
|
+
TestBedRender3.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
1993
2005
|
var testBed = _getTestBedRender3();
|
|
1994
|
-
testBed.initTestEnvironment(ngModule, platform,
|
|
2006
|
+
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
|
|
1995
2007
|
return testBed;
|
|
1996
2008
|
};
|
|
1997
2009
|
/**
|
|
@@ -2072,6 +2084,12 @@
|
|
|
2072
2084
|
_getTestBedRender3().resetTestingModule();
|
|
2073
2085
|
return TestBedRender3;
|
|
2074
2086
|
};
|
|
2087
|
+
TestBedRender3.shouldTearDownTestingModule = function () {
|
|
2088
|
+
return _getTestBedRender3().shouldTearDownTestingModule();
|
|
2089
|
+
};
|
|
2090
|
+
TestBedRender3.tearDownTestingModule = function () {
|
|
2091
|
+
_getTestBedRender3().tearDownTestingModule();
|
|
2092
|
+
};
|
|
2075
2093
|
/**
|
|
2076
2094
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
2077
2095
|
* angular module. These are common to every test in the suite.
|
|
@@ -2085,10 +2103,14 @@
|
|
|
2085
2103
|
*
|
|
2086
2104
|
* @publicApi
|
|
2087
2105
|
*/
|
|
2088
|
-
TestBedRender3.prototype.initTestEnvironment = function (ngModule, platform,
|
|
2106
|
+
TestBedRender3.prototype.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2089
2107
|
if (this.platform || this.ngModule) {
|
|
2090
2108
|
throw new Error('Cannot set base providers because it has already been called');
|
|
2091
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;
|
|
2092
2114
|
this.platform = platform;
|
|
2093
2115
|
this.ngModule = ngModule;
|
|
2094
2116
|
this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
|
|
@@ -2103,6 +2125,7 @@
|
|
|
2103
2125
|
this._compiler = null;
|
|
2104
2126
|
this.platform = null;
|
|
2105
2127
|
this.ngModule = null;
|
|
2128
|
+
TestBedRender3._environmentTeardownOptions = undefined;
|
|
2106
2129
|
};
|
|
2107
2130
|
TestBedRender3.prototype.resetTestingModule = function () {
|
|
2108
2131
|
this.checkGlobalCompilationFinished();
|
|
@@ -2111,8 +2134,23 @@
|
|
|
2111
2134
|
this.compiler.restoreOriginalState();
|
|
2112
2135
|
}
|
|
2113
2136
|
this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
|
|
2114
|
-
|
|
2115
|
-
|
|
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
|
+
}
|
|
2116
2154
|
};
|
|
2117
2155
|
TestBedRender3.prototype.configureCompiler = function (config) {
|
|
2118
2156
|
if (config.useJit != null) {
|
|
@@ -2124,6 +2162,9 @@
|
|
|
2124
2162
|
};
|
|
2125
2163
|
TestBedRender3.prototype.configureTestingModule = function (moduleDef) {
|
|
2126
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;
|
|
2127
2168
|
this.compiler.configureTestingModule(moduleDef);
|
|
2128
2169
|
};
|
|
2129
2170
|
TestBedRender3.prototype.compileComponents = function () {
|
|
@@ -2254,11 +2295,13 @@
|
|
|
2254
2295
|
this._globalCompilationChecked = true;
|
|
2255
2296
|
};
|
|
2256
2297
|
TestBedRender3.prototype.destroyActiveFixtures = function () {
|
|
2298
|
+
var errorCount = 0;
|
|
2257
2299
|
this._activeFixtures.forEach(function (fixture) {
|
|
2258
2300
|
try {
|
|
2259
2301
|
fixture.destroy();
|
|
2260
2302
|
}
|
|
2261
2303
|
catch (e) {
|
|
2304
|
+
errorCount++;
|
|
2262
2305
|
console.error('Error during cleanup of component', {
|
|
2263
2306
|
component: fixture.componentInstance,
|
|
2264
2307
|
stacktrace: e,
|
|
@@ -2266,6 +2309,52 @@
|
|
|
2266
2309
|
}
|
|
2267
2310
|
});
|
|
2268
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
|
+
}
|
|
2269
2358
|
};
|
|
2270
2359
|
return TestBedRender3;
|
|
2271
2360
|
}());
|
|
@@ -2390,9 +2479,9 @@
|
|
|
2390
2479
|
* Test modules and platforms for individual platforms are available from
|
|
2391
2480
|
* '@angular/<platform_name>/testing'.
|
|
2392
2481
|
*/
|
|
2393
|
-
TestBedViewEngine.initTestEnvironment = function (ngModule, platform,
|
|
2482
|
+
TestBedViewEngine.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2394
2483
|
var testBed = _getTestBedViewEngine();
|
|
2395
|
-
testBed.initTestEnvironment(ngModule, platform,
|
|
2484
|
+
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
|
|
2396
2485
|
return testBed;
|
|
2397
2486
|
};
|
|
2398
2487
|
/**
|
|
@@ -2475,6 +2564,12 @@
|
|
|
2475
2564
|
TestBedViewEngine.createComponent = function (component) {
|
|
2476
2565
|
return _getTestBedViewEngine().createComponent(component);
|
|
2477
2566
|
};
|
|
2567
|
+
TestBedViewEngine.shouldTearDownTestingModule = function () {
|
|
2568
|
+
return _getTestBedViewEngine().shouldTearDownTestingModule();
|
|
2569
|
+
};
|
|
2570
|
+
TestBedViewEngine.tearDownTestingModule = function () {
|
|
2571
|
+
_getTestBedViewEngine().tearDownTestingModule();
|
|
2572
|
+
};
|
|
2478
2573
|
/**
|
|
2479
2574
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
2480
2575
|
* angular module. These are common to every test in the suite.
|
|
@@ -2486,14 +2581,19 @@
|
|
|
2486
2581
|
* Test modules and platforms for individual platforms are available from
|
|
2487
2582
|
* '@angular/<platform_name>/testing'.
|
|
2488
2583
|
*/
|
|
2489
|
-
TestBedViewEngine.prototype.initTestEnvironment = function (ngModule, platform,
|
|
2584
|
+
TestBedViewEngine.prototype.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
|
|
2490
2585
|
if (this.platform || this.ngModule) {
|
|
2491
2586
|
throw new Error('Cannot set base providers because it has already been called');
|
|
2492
2587
|
}
|
|
2493
2588
|
this.platform = platform;
|
|
2494
2589
|
this.ngModule = ngModule;
|
|
2495
|
-
if (
|
|
2496
|
-
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;
|
|
2497
2597
|
}
|
|
2498
2598
|
};
|
|
2499
2599
|
/**
|
|
@@ -2504,6 +2604,7 @@
|
|
|
2504
2604
|
this.platform = null;
|
|
2505
2605
|
this.ngModule = null;
|
|
2506
2606
|
this._testEnvAotSummaries = function () { return []; };
|
|
2607
|
+
TestBedViewEngine._environmentTeardownOptions = undefined;
|
|
2507
2608
|
};
|
|
2508
2609
|
TestBedViewEngine.prototype.resetTestingModule = function () {
|
|
2509
2610
|
core.ɵclearOverrides();
|
|
@@ -2516,49 +2617,56 @@
|
|
|
2516
2617
|
this._pipeOverrides = [];
|
|
2517
2618
|
this._isRoot = true;
|
|
2518
2619
|
this._rootProviderOverrides = [];
|
|
2519
|
-
this._moduleRef = null;
|
|
2520
2620
|
this._moduleFactory = null;
|
|
2521
2621
|
this._compilerOptions = [];
|
|
2522
2622
|
this._providers = [];
|
|
2523
2623
|
this._declarations = [];
|
|
2524
2624
|
this._imports = [];
|
|
2525
2625
|
this._schemas = [];
|
|
2526
|
-
|
|
2527
|
-
|
|
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 {
|
|
2528
2633
|
try {
|
|
2529
|
-
|
|
2634
|
+
if (this.shouldTearDownTestingModule()) {
|
|
2635
|
+
this.tearDownTestingModule();
|
|
2636
|
+
}
|
|
2530
2637
|
}
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
});
|
|
2638
|
+
finally {
|
|
2639
|
+
this._moduleRef = null;
|
|
2640
|
+
this._instanceTeardownOptions = undefined;
|
|
2641
|
+
this._instantiated = false;
|
|
2536
2642
|
}
|
|
2537
|
-
}
|
|
2538
|
-
this._activeFixtures = [];
|
|
2643
|
+
}
|
|
2539
2644
|
};
|
|
2540
2645
|
TestBedViewEngine.prototype.configureCompiler = function (config) {
|
|
2541
2646
|
this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
|
|
2542
2647
|
this._compilerOptions.push(config);
|
|
2543
2648
|
};
|
|
2544
2649
|
TestBedViewEngine.prototype.configureTestingModule = function (moduleDef) {
|
|
2545
|
-
var
|
|
2650
|
+
var _f, _g, _h, _j;
|
|
2546
2651
|
this._assertNotInstantiated('TestBed.configureTestingModule', 'configure the test module');
|
|
2547
2652
|
if (moduleDef.providers) {
|
|
2548
|
-
(
|
|
2653
|
+
(_f = this._providers).push.apply(_f, __spreadArray([], __read(moduleDef.providers)));
|
|
2549
2654
|
}
|
|
2550
2655
|
if (moduleDef.declarations) {
|
|
2551
|
-
(
|
|
2656
|
+
(_g = this._declarations).push.apply(_g, __spreadArray([], __read(moduleDef.declarations)));
|
|
2552
2657
|
}
|
|
2553
2658
|
if (moduleDef.imports) {
|
|
2554
|
-
(
|
|
2659
|
+
(_h = this._imports).push.apply(_h, __spreadArray([], __read(moduleDef.imports)));
|
|
2555
2660
|
}
|
|
2556
2661
|
if (moduleDef.schemas) {
|
|
2557
|
-
(
|
|
2662
|
+
(_j = this._schemas).push.apply(_j, __spreadArray([], __read(moduleDef.schemas)));
|
|
2558
2663
|
}
|
|
2559
2664
|
if (moduleDef.aotSummaries) {
|
|
2560
2665
|
this._aotSummaries.push(moduleDef.aotSummaries);
|
|
2561
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;
|
|
2562
2670
|
};
|
|
2563
2671
|
TestBedViewEngine.prototype.compileComponents = function () {
|
|
2564
2672
|
var _this = this;
|
|
@@ -2572,7 +2680,7 @@
|
|
|
2572
2680
|
});
|
|
2573
2681
|
};
|
|
2574
2682
|
TestBedViewEngine.prototype._initIfNeeded = function () {
|
|
2575
|
-
var e_1,
|
|
2683
|
+
var e_1, _f;
|
|
2576
2684
|
if (this._instantiated) {
|
|
2577
2685
|
return;
|
|
2578
2686
|
}
|
|
@@ -2594,8 +2702,8 @@
|
|
|
2594
2702
|
}
|
|
2595
2703
|
}
|
|
2596
2704
|
try {
|
|
2597
|
-
for (var
|
|
2598
|
-
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;
|
|
2599
2707
|
var compFactory = this._compiler.getComponentFactory(templateOf);
|
|
2600
2708
|
core.ɵoverrideComponentView(component, compFactory);
|
|
2601
2709
|
}
|
|
@@ -2603,7 +2711,7 @@
|
|
|
2603
2711
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2604
2712
|
finally {
|
|
2605
2713
|
try {
|
|
2606
|
-
if (
|
|
2714
|
+
if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
|
|
2607
2715
|
}
|
|
2608
2716
|
finally { if (e_1) throw e_1.error; }
|
|
2609
2717
|
}
|
|
@@ -2621,7 +2729,7 @@
|
|
|
2621
2729
|
this._instantiated = true;
|
|
2622
2730
|
};
|
|
2623
2731
|
TestBedViewEngine.prototype._createCompilerAndModule = function () {
|
|
2624
|
-
var e_2,
|
|
2732
|
+
var e_2, _f;
|
|
2625
2733
|
var _this = this;
|
|
2626
2734
|
var providers = this._providers.concat([{ provide: TestBed, useValue: this }]);
|
|
2627
2735
|
var declarations = __spreadArray(__spreadArray([], __read(this._declarations)), __read(this._templateOverrides.map(function (entry) { return entry.templateOf; })));
|
|
@@ -2655,15 +2763,15 @@
|
|
|
2655
2763
|
var compilerFactory = this.platform.injector.get(TestingCompilerFactory);
|
|
2656
2764
|
this._compiler = compilerFactory.createTestingCompiler(this._compilerOptions);
|
|
2657
2765
|
try {
|
|
2658
|
-
for (var
|
|
2659
|
-
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;
|
|
2660
2768
|
this._compiler.loadAotSummaries(summary);
|
|
2661
2769
|
}
|
|
2662
2770
|
}
|
|
2663
2771
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2664
2772
|
finally {
|
|
2665
2773
|
try {
|
|
2666
|
-
if (
|
|
2774
|
+
if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
|
|
2667
2775
|
}
|
|
2668
2776
|
finally { if (e_2) throw e_2.error; }
|
|
2669
2777
|
}
|
|
@@ -2802,6 +2910,68 @@
|
|
|
2802
2910
|
this._activeFixtures.push(fixture);
|
|
2803
2911
|
return fixture;
|
|
2804
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
|
+
};
|
|
2805
2975
|
return TestBedViewEngine;
|
|
2806
2976
|
}());
|
|
2807
2977
|
/**
|
|
@@ -2902,10 +3072,22 @@
|
|
|
2902
3072
|
var _global = (typeof window === 'undefined' ? global : window);
|
|
2903
3073
|
// Reset the test providers and the fake async zone before each test.
|
|
2904
3074
|
if (_global.beforeEach) {
|
|
2905
|
-
_global.beforeEach(
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
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
|
+
};
|
|
2909
3091
|
}
|
|
2910
3092
|
/**
|
|
2911
3093
|
* This API should be removed. But doing so seems to break `google3` and so it requires a bit of
|