Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: angular 14.2 mount compilation error #23593

Merged
merged 4 commits into from
Aug 29, 2022
Merged

Conversation

ZachJW34
Copy link
Contributor

User facing changelog

Fix Angular 14.2 mount compilation error

Additional details

Angulars 14.2 update changed the API we relied on for tearing down the component between tests. Before 14.2, tearDownTestingModule was a static method on the TestBed class but was changed to be a method on the instance. Converting all TestBed references to the getTestBed() factory function gives us the proper instance of TestBed with the methods we need and reatins backwards compatibility.

Steps to test

Running the system tests in system-tests/test/component_testing_spec.ts is the best way to test. The angular-14 project has had it's deps bumped. Without the changes to mount this test will fail.

How has the user experience changed?

Screen.Recording.2022-08-29.at.11.01.34.AM.mov

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • [na] Has a PR for user-facing changes been opened in cypress-documentation?
  • [na] Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 29, 2022

Thanks for taking the time to open a PR!

@cypress
Copy link

cypress bot commented Aug 29, 2022



Test summary

39641 0 3371 0Flakiness 1


Run details

Project cypress
Status Passed
Commit d6cdd3b
Started Aug 29, 2022 5:35 PM
Ended Aug 29, 2022 5:49 PM
Duration 14:18 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

cypress/e2e/e2e/origin/basic_login.cy.ts Flakiness
1 basic login > visit primary first > does not redirect

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@@ -309,6 +308,6 @@ getTestBed().initTestEnvironment(

setupHooks(() => {
// Not public, we need to call this to remove the last component from the DOM
TestBed['tearDownTestingModule']()
TestBed.resetTestingModule()
getTestBed()['tearDownTestingModule']()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this function isn't part of the public API for TestBed? Would it make sense to guard it with a try/catch to keep us from blowing up, or would that just break tests in a less-obvious way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An error thrown here makes sense, since otherwise it would lead to some really strange behavior (like not removing the previously mounted component). Since it threw, it was very easy to track down what was going on and get a fix for it.

It is marked as a public property, just not exposed on the interface for some reason.

@ZachJW34 ZachJW34 merged commit 2f337db into develop Aug 29, 2022
@ZachJW34 ZachJW34 deleted the zachw/angular-14-2 branch August 29, 2022 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular Component Test broken by changes in Angular 14.2.0 (tearDownTestingModule)
3 participants