@angular/core 12.1.0-next.4 → 12.1.1
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 +65 -28
- package/bundles/core.umd.js.map +1 -1
- package/core.d.ts +85 -10
- 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/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/linker/view_container_ref.js +1 -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 +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 +55 -24
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/testing.js +202 -26
- 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 -5
- package/testing/testing.metadata.json +1 -1
- package/testing.d.ts +1 -1
- package/esm2015/testing/src/before_each.js +0 -33
package/fesm2015/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.1.
|
|
2
|
+
* @license Angular v12.1.1
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -1469,6 +1469,11 @@ class R3TestCompiler {
|
|
|
1469
1469
|
* Use of this source code is governed by an MIT-style license that can be
|
|
1470
1470
|
* found in the LICENSE file at https://angular.io/license
|
|
1471
1471
|
*/
|
|
1472
|
+
/**
|
|
1473
|
+
* Whether test modules should be torn down by default.
|
|
1474
|
+
* Currently disabled for backwards-compatibility reasons.
|
|
1475
|
+
*/
|
|
1476
|
+
const TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = false;
|
|
1472
1477
|
/**
|
|
1473
1478
|
* An abstract class for inserting the root test component element in a platform independent way.
|
|
1474
1479
|
*
|
|
@@ -1476,6 +1481,7 @@ class R3TestCompiler {
|
|
|
1476
1481
|
*/
|
|
1477
1482
|
class TestComponentRenderer {
|
|
1478
1483
|
insertRootElement(rootElementId) { }
|
|
1484
|
+
removeAllRootElements() { }
|
|
1479
1485
|
}
|
|
1480
1486
|
/**
|
|
1481
1487
|
* @publicApi
|
|
@@ -1527,9 +1533,9 @@ class TestBedRender3 {
|
|
|
1527
1533
|
*
|
|
1528
1534
|
* @publicApi
|
|
1529
1535
|
*/
|
|
1530
|
-
static initTestEnvironment(ngModule, platform,
|
|
1536
|
+
static initTestEnvironment(ngModule, platform, summariesOrOptions) {
|
|
1531
1537
|
const testBed = _getTestBedRender3();
|
|
1532
|
-
testBed.initTestEnvironment(ngModule, platform,
|
|
1538
|
+
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
|
|
1533
1539
|
return testBed;
|
|
1534
1540
|
}
|
|
1535
1541
|
/**
|
|
@@ -1608,6 +1614,12 @@ class TestBedRender3 {
|
|
|
1608
1614
|
_getTestBedRender3().resetTestingModule();
|
|
1609
1615
|
return TestBedRender3;
|
|
1610
1616
|
}
|
|
1617
|
+
static shouldTearDownTestingModule() {
|
|
1618
|
+
return _getTestBedRender3().shouldTearDownTestingModule();
|
|
1619
|
+
}
|
|
1620
|
+
static tearDownTestingModule() {
|
|
1621
|
+
_getTestBedRender3().tearDownTestingModule();
|
|
1622
|
+
}
|
|
1611
1623
|
/**
|
|
1612
1624
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
1613
1625
|
* angular module. These are common to every test in the suite.
|
|
@@ -1621,10 +1633,14 @@ class TestBedRender3 {
|
|
|
1621
1633
|
*
|
|
1622
1634
|
* @publicApi
|
|
1623
1635
|
*/
|
|
1624
|
-
initTestEnvironment(ngModule, platform,
|
|
1636
|
+
initTestEnvironment(ngModule, platform, summariesOrOptions) {
|
|
1625
1637
|
if (this.platform || this.ngModule) {
|
|
1626
1638
|
throw new Error('Cannot set base providers because it has already been called');
|
|
1627
1639
|
}
|
|
1640
|
+
// If `summariesOrOptions` is a function, it means that it's
|
|
1641
|
+
// an AOT summaries factory which Ivy doesn't support.
|
|
1642
|
+
TestBedRender3._environmentTeardownOptions =
|
|
1643
|
+
typeof summariesOrOptions === 'function' ? undefined : summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.teardown;
|
|
1628
1644
|
this.platform = platform;
|
|
1629
1645
|
this.ngModule = ngModule;
|
|
1630
1646
|
this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
|
|
@@ -1639,6 +1655,7 @@ class TestBedRender3 {
|
|
|
1639
1655
|
this._compiler = null;
|
|
1640
1656
|
this.platform = null;
|
|
1641
1657
|
this.ngModule = null;
|
|
1658
|
+
TestBedRender3._environmentTeardownOptions = undefined;
|
|
1642
1659
|
}
|
|
1643
1660
|
resetTestingModule() {
|
|
1644
1661
|
this.checkGlobalCompilationFinished();
|
|
@@ -1647,8 +1664,23 @@ class TestBedRender3 {
|
|
|
1647
1664
|
this.compiler.restoreOriginalState();
|
|
1648
1665
|
}
|
|
1649
1666
|
this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
|
|
1650
|
-
|
|
1651
|
-
|
|
1667
|
+
// We have to chain a couple of try/finally blocks, because each step can
|
|
1668
|
+
// throw errors and we don't want it to interrupt the next step and we also
|
|
1669
|
+
// want an error to be thrown at the end.
|
|
1670
|
+
try {
|
|
1671
|
+
this.destroyActiveFixtures();
|
|
1672
|
+
}
|
|
1673
|
+
finally {
|
|
1674
|
+
try {
|
|
1675
|
+
if (this.shouldTearDownTestingModule()) {
|
|
1676
|
+
this.tearDownTestingModule();
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
finally {
|
|
1680
|
+
this._testModuleRef = null;
|
|
1681
|
+
this._instanceTeardownOptions = undefined;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1652
1684
|
}
|
|
1653
1685
|
configureCompiler(config) {
|
|
1654
1686
|
if (config.useJit != null) {
|
|
@@ -1660,6 +1692,9 @@ class TestBedRender3 {
|
|
|
1660
1692
|
}
|
|
1661
1693
|
configureTestingModule(moduleDef) {
|
|
1662
1694
|
this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
|
|
1695
|
+
// Always re-assign the teardown options, even if they're undefined.
|
|
1696
|
+
// This ensures that we don't carry the options between tests.
|
|
1697
|
+
this._instanceTeardownOptions = moduleDef.teardown;
|
|
1663
1698
|
this.compiler.configureTestingModule(moduleDef);
|
|
1664
1699
|
}
|
|
1665
1700
|
compileComponents() {
|
|
@@ -1778,11 +1813,13 @@ class TestBedRender3 {
|
|
|
1778
1813
|
this._globalCompilationChecked = true;
|
|
1779
1814
|
}
|
|
1780
1815
|
destroyActiveFixtures() {
|
|
1816
|
+
let errorCount = 0;
|
|
1781
1817
|
this._activeFixtures.forEach((fixture) => {
|
|
1782
1818
|
try {
|
|
1783
1819
|
fixture.destroy();
|
|
1784
1820
|
}
|
|
1785
1821
|
catch (e) {
|
|
1822
|
+
errorCount++;
|
|
1786
1823
|
console.error('Error during cleanup of component', {
|
|
1787
1824
|
component: fixture.componentInstance,
|
|
1788
1825
|
stacktrace: e,
|
|
@@ -1790,6 +1827,52 @@ class TestBedRender3 {
|
|
|
1790
1827
|
}
|
|
1791
1828
|
});
|
|
1792
1829
|
this._activeFixtures = [];
|
|
1830
|
+
if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
|
|
1831
|
+
throw Error(`${errorCount} ${(errorCount === 1 ? 'component' : 'components')} ` +
|
|
1832
|
+
`threw errors during cleanup`);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
shouldRethrowTeardownErrors() {
|
|
1836
|
+
var _a, _b;
|
|
1837
|
+
const instanceOptions = this._instanceTeardownOptions;
|
|
1838
|
+
const environmentOptions = TestBedRender3._environmentTeardownOptions;
|
|
1839
|
+
// If the new teardown behavior hasn't been configured, preserve the old behavior.
|
|
1840
|
+
if (!instanceOptions && !environmentOptions) {
|
|
1841
|
+
return false;
|
|
1842
|
+
}
|
|
1843
|
+
// Otherwise use the configured behavior or default to rethrowing.
|
|
1844
|
+
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;
|
|
1845
|
+
}
|
|
1846
|
+
shouldTearDownTestingModule() {
|
|
1847
|
+
var _a, _b, _c, _d;
|
|
1848
|
+
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;
|
|
1849
|
+
}
|
|
1850
|
+
tearDownTestingModule() {
|
|
1851
|
+
var _a;
|
|
1852
|
+
// If the module ref has already been destroyed, we won't be able to get a test renderer.
|
|
1853
|
+
if (this._testModuleRef === null) {
|
|
1854
|
+
return;
|
|
1855
|
+
}
|
|
1856
|
+
// Resolve the renderer ahead of time, because we want to remove the root elements as the very
|
|
1857
|
+
// last step, but the injector will be destroyed as a part of the module ref destruction.
|
|
1858
|
+
const testRenderer = this.inject(TestComponentRenderer);
|
|
1859
|
+
try {
|
|
1860
|
+
this._testModuleRef.destroy();
|
|
1861
|
+
}
|
|
1862
|
+
catch (e) {
|
|
1863
|
+
if (this.shouldRethrowTeardownErrors()) {
|
|
1864
|
+
throw e;
|
|
1865
|
+
}
|
|
1866
|
+
else {
|
|
1867
|
+
console.error('Error during cleanup of a testing module', {
|
|
1868
|
+
component: this._testModuleRef.instance,
|
|
1869
|
+
stacktrace: e,
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
finally {
|
|
1874
|
+
(_a = testRenderer.removeAllRootElements) === null || _a === void 0 ? void 0 : _a.call(testRenderer);
|
|
1875
|
+
}
|
|
1793
1876
|
}
|
|
1794
1877
|
}
|
|
1795
1878
|
let testBed;
|
|
@@ -1915,9 +1998,9 @@ class TestBedViewEngine {
|
|
|
1915
1998
|
* Test modules and platforms for individual platforms are available from
|
|
1916
1999
|
* '@angular/<platform_name>/testing'.
|
|
1917
2000
|
*/
|
|
1918
|
-
static initTestEnvironment(ngModule, platform,
|
|
2001
|
+
static initTestEnvironment(ngModule, platform, summariesOrOptions) {
|
|
1919
2002
|
const testBed = _getTestBedViewEngine();
|
|
1920
|
-
testBed.initTestEnvironment(ngModule, platform,
|
|
2003
|
+
testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
|
|
1921
2004
|
return testBed;
|
|
1922
2005
|
}
|
|
1923
2006
|
/**
|
|
@@ -1998,6 +2081,12 @@ class TestBedViewEngine {
|
|
|
1998
2081
|
static createComponent(component) {
|
|
1999
2082
|
return _getTestBedViewEngine().createComponent(component);
|
|
2000
2083
|
}
|
|
2084
|
+
static shouldTearDownTestingModule() {
|
|
2085
|
+
return _getTestBedViewEngine().shouldTearDownTestingModule();
|
|
2086
|
+
}
|
|
2087
|
+
static tearDownTestingModule() {
|
|
2088
|
+
_getTestBedViewEngine().tearDownTestingModule();
|
|
2089
|
+
}
|
|
2001
2090
|
/**
|
|
2002
2091
|
* Initialize the environment for testing with a compiler factory, a PlatformRef, and an
|
|
2003
2092
|
* angular module. These are common to every test in the suite.
|
|
@@ -2009,14 +2098,19 @@ class TestBedViewEngine {
|
|
|
2009
2098
|
* Test modules and platforms for individual platforms are available from
|
|
2010
2099
|
* '@angular/<platform_name>/testing'.
|
|
2011
2100
|
*/
|
|
2012
|
-
initTestEnvironment(ngModule, platform,
|
|
2101
|
+
initTestEnvironment(ngModule, platform, summariesOrOptions) {
|
|
2013
2102
|
if (this.platform || this.ngModule) {
|
|
2014
2103
|
throw new Error('Cannot set base providers because it has already been called');
|
|
2015
2104
|
}
|
|
2016
2105
|
this.platform = platform;
|
|
2017
2106
|
this.ngModule = ngModule;
|
|
2018
|
-
if (
|
|
2019
|
-
this._testEnvAotSummaries =
|
|
2107
|
+
if (typeof summariesOrOptions === 'function') {
|
|
2108
|
+
this._testEnvAotSummaries = summariesOrOptions;
|
|
2109
|
+
TestBedViewEngine._environmentTeardownOptions = undefined;
|
|
2110
|
+
}
|
|
2111
|
+
else {
|
|
2112
|
+
this._testEnvAotSummaries = (summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.aotSummaries) || (() => []);
|
|
2113
|
+
TestBedViewEngine._environmentTeardownOptions = summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.teardown;
|
|
2020
2114
|
}
|
|
2021
2115
|
}
|
|
2022
2116
|
/**
|
|
@@ -2027,6 +2121,7 @@ class TestBedViewEngine {
|
|
|
2027
2121
|
this.platform = null;
|
|
2028
2122
|
this.ngModule = null;
|
|
2029
2123
|
this._testEnvAotSummaries = () => [];
|
|
2124
|
+
TestBedViewEngine._environmentTeardownOptions = undefined;
|
|
2030
2125
|
}
|
|
2031
2126
|
resetTestingModule() {
|
|
2032
2127
|
ɵclearOverrides();
|
|
@@ -2039,26 +2134,30 @@ class TestBedViewEngine {
|
|
|
2039
2134
|
this._pipeOverrides = [];
|
|
2040
2135
|
this._isRoot = true;
|
|
2041
2136
|
this._rootProviderOverrides = [];
|
|
2042
|
-
this._moduleRef = null;
|
|
2043
2137
|
this._moduleFactory = null;
|
|
2044
2138
|
this._compilerOptions = [];
|
|
2045
2139
|
this._providers = [];
|
|
2046
2140
|
this._declarations = [];
|
|
2047
2141
|
this._imports = [];
|
|
2048
2142
|
this._schemas = [];
|
|
2049
|
-
|
|
2050
|
-
|
|
2143
|
+
// We have to chain a couple of try/finally blocks, because each step can
|
|
2144
|
+
// throw errors and we don't want it to interrupt the next step and we also
|
|
2145
|
+
// want an error to be thrown at the end.
|
|
2146
|
+
try {
|
|
2147
|
+
this.destroyActiveFixtures();
|
|
2148
|
+
}
|
|
2149
|
+
finally {
|
|
2051
2150
|
try {
|
|
2052
|
-
|
|
2151
|
+
if (this.shouldTearDownTestingModule()) {
|
|
2152
|
+
this.tearDownTestingModule();
|
|
2153
|
+
}
|
|
2053
2154
|
}
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
});
|
|
2155
|
+
finally {
|
|
2156
|
+
this._moduleRef = null;
|
|
2157
|
+
this._instanceTeardownOptions = undefined;
|
|
2158
|
+
this._instantiated = false;
|
|
2059
2159
|
}
|
|
2060
|
-
}
|
|
2061
|
-
this._activeFixtures = [];
|
|
2160
|
+
}
|
|
2062
2161
|
}
|
|
2063
2162
|
configureCompiler(config) {
|
|
2064
2163
|
this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
|
|
@@ -2081,6 +2180,9 @@ class TestBedViewEngine {
|
|
|
2081
2180
|
if (moduleDef.aotSummaries) {
|
|
2082
2181
|
this._aotSummaries.push(moduleDef.aotSummaries);
|
|
2083
2182
|
}
|
|
2183
|
+
// Always re-assign the teardown options, even if they're undefined.
|
|
2184
|
+
// This ensures that we don't carry the options between tests.
|
|
2185
|
+
this._instanceTeardownOptions = moduleDef.teardown;
|
|
2084
2186
|
}
|
|
2085
2187
|
compileComponents() {
|
|
2086
2188
|
if (this._moduleFactory || this._instantiated) {
|
|
@@ -2288,6 +2390,68 @@ class TestBedViewEngine {
|
|
|
2288
2390
|
this._activeFixtures.push(fixture);
|
|
2289
2391
|
return fixture;
|
|
2290
2392
|
}
|
|
2393
|
+
destroyActiveFixtures() {
|
|
2394
|
+
let errorCount = 0;
|
|
2395
|
+
this._activeFixtures.forEach((fixture) => {
|
|
2396
|
+
try {
|
|
2397
|
+
fixture.destroy();
|
|
2398
|
+
}
|
|
2399
|
+
catch (e) {
|
|
2400
|
+
errorCount++;
|
|
2401
|
+
console.error('Error during cleanup of component', {
|
|
2402
|
+
component: fixture.componentInstance,
|
|
2403
|
+
stacktrace: e,
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2406
|
+
});
|
|
2407
|
+
this._activeFixtures = [];
|
|
2408
|
+
if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
|
|
2409
|
+
throw Error(`${errorCount} ${(errorCount === 1 ? 'component' : 'components')} ` +
|
|
2410
|
+
`threw errors during cleanup`);
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
shouldRethrowTeardownErrors() {
|
|
2414
|
+
var _a, _b;
|
|
2415
|
+
const instanceOptions = this._instanceTeardownOptions;
|
|
2416
|
+
const environmentOptions = TestBedViewEngine._environmentTeardownOptions;
|
|
2417
|
+
// If the new teardown behavior hasn't been configured, preserve the old behavior.
|
|
2418
|
+
if (!instanceOptions && !environmentOptions) {
|
|
2419
|
+
return false;
|
|
2420
|
+
}
|
|
2421
|
+
// Otherwise use the configured behavior or default to rethrowing.
|
|
2422
|
+
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;
|
|
2423
|
+
}
|
|
2424
|
+
shouldTearDownTestingModule() {
|
|
2425
|
+
var _a, _b, _c, _d;
|
|
2426
|
+
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;
|
|
2427
|
+
}
|
|
2428
|
+
tearDownTestingModule() {
|
|
2429
|
+
var _a, _b, _c, _d, _e;
|
|
2430
|
+
// If the module ref has already been destroyed, we won't be able to get a test renderer.
|
|
2431
|
+
if (this._moduleRef === null) {
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
// Resolve the renderer ahead of time, because we want to remove the root elements as the very
|
|
2435
|
+
// last step, but the injector will be destroyed as a part of the module ref destruction.
|
|
2436
|
+
const testRenderer = this.inject(TestComponentRenderer);
|
|
2437
|
+
try {
|
|
2438
|
+
this._moduleRef.destroy();
|
|
2439
|
+
}
|
|
2440
|
+
catch (e) {
|
|
2441
|
+
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) {
|
|
2442
|
+
throw e;
|
|
2443
|
+
}
|
|
2444
|
+
else {
|
|
2445
|
+
console.error('Error during cleanup of a testing module', {
|
|
2446
|
+
component: this._moduleRef.instance,
|
|
2447
|
+
stacktrace: e,
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
finally {
|
|
2452
|
+
(_e = testRenderer === null || testRenderer === void 0 ? void 0 : testRenderer.removeAllRootElements) === null || _e === void 0 ? void 0 : _e.call(testRenderer);
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2291
2455
|
}
|
|
2292
2456
|
/**
|
|
2293
2457
|
* @description
|
|
@@ -2386,10 +2550,22 @@ function withModule(moduleDef, fn) {
|
|
|
2386
2550
|
const _global = (typeof window === 'undefined' ? global : window);
|
|
2387
2551
|
// Reset the test providers and the fake async zone before each test.
|
|
2388
2552
|
if (_global.beforeEach) {
|
|
2389
|
-
_global.beforeEach(()
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2553
|
+
_global.beforeEach(getCleanupHook(false));
|
|
2554
|
+
}
|
|
2555
|
+
// We provide both a `beforeEach` and `afterEach`, because the updated behavior for
|
|
2556
|
+
// tearing down the module is supposed to run after the test so that we can associate
|
|
2557
|
+
// teardown errors with the correct test.
|
|
2558
|
+
if (_global.afterEach) {
|
|
2559
|
+
_global.afterEach(getCleanupHook(true));
|
|
2560
|
+
}
|
|
2561
|
+
function getCleanupHook(expectedTeardownValue) {
|
|
2562
|
+
return () => {
|
|
2563
|
+
if (TestBed.shouldTearDownTestingModule() ===
|
|
2564
|
+
expectedTeardownValue) {
|
|
2565
|
+
TestBed.resetTestingModule();
|
|
2566
|
+
resetFakeAsyncZone();
|
|
2567
|
+
}
|
|
2568
|
+
};
|
|
2393
2569
|
}
|
|
2394
2570
|
/**
|
|
2395
2571
|
* This API should be removed. But doing so seems to break `google3` and so it requires a bit of
|