test(upgrade): properly clean up after tests to avoid errors in unrelated tests (#28013)
Many `ngUpgrade` tests need to manually [bootstrap modules][1] (instead of using `TestBed` which automatically cleans up) and thus need to also manually clean up afterwards (e.g. by calling [destroyPlatform()][2] after each test). Failing to destroy the platform is usually not a problem, unless the next test tries to manually destroy it (as a precaution), as happens [here][3] (among other places). More specifically, the problem happens, because (as part of the clean-up happening on platform destruction) upgraded components will try to [call a method][4] on `angular.element` after `angular` has been [set to `undefined`][5] (assuming the last test was using the [withEachNg1Version()][6] helper). Because the test order is pseudo-random and thus different on each run, these errors did not always come up and - when they did- they would go away after a couple of reruns, making them appear as flakes on CI. (For reference, the issue was introduced in 43c33d566.) This commit eliminates the issue by always destroying the platform after each `ngUpgrade` test. Jira issue: FW-924 [1]:c3aa24c3f9/packages/upgrade/test/static/test_helpers.ts (L21)
[2]:c3aa24c3f9/packages/upgrade/test/static/integration/upgrade_component_spec.ts (L24)
[3]:c3aa24c3f9/packages/elements/test/create-custom-element_spec.ts (L31)
[4]:c3aa24c3f9/packages/upgrade/src/common/upgrade_helper.ts (L134-L135)
[5]:c3aa24c3f9/packages/upgrade/test/common/test_helpers.ts (L115)
[6]:c3aa24c3f9/packages/upgrade/test/common/test_helpers.ts (L31)
PR Close #28013
This commit is contained in:
parent
c3aa24c3f9
commit
4e17212d44
|
@ -25,6 +25,7 @@ withEachNg1Version(() => {
|
|||
describe(`lazy-load ng2 module (propagateDigest: ${propagateDigest})`, () => {
|
||||
|
||||
beforeEach(() => destroyPlatform());
|
||||
afterEach(() => destroyPlatform());
|
||||
|
||||
it('should support multiple downgraded modules', async(() => {
|
||||
@Component({selector: 'ng2A', template: 'a'})
|
||||
|
|
Loading…
Reference in New Issue