Skip to content

refactor(input): switch to fakeAsync tests #8490

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

Merged
merged 1 commit into from
Nov 20, 2017

Conversation

crisbeto
Copy link
Member

Moves all of the input tests away from the async zone either to the default one or to fakeAsync.

@crisbeto crisbeto requested a review from mmalerba as a code owner November 16, 2017 21:14
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 16, 2017
@@ -160,7 +160,7 @@ describe('MatInput without forms', function () {
expect(el.classList.contains('mat-form-field-empty')).toBe(true);
});

it('should not be empty after input entered', async(() => {
it('should not be empty after input entered', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make these fakeAsync as well? if they do async things in their constructor or lifecycle hooks they could silently leak async operations. I like that fakeAsync fails if you don't flush it - no more time wasted binary searching for the leaky test

Copy link
Member Author

Choose a reason for hiding this comment

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

I think they were async to begin with because we just had one async and then we copy-pasted it when we wrote new tests, but they don't really need to be. As for those silent error leaks, I believe they only happen with the async zone which we won't use anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, so what happens if we don't mark something fakeAsync but it actually does do async stuff? Even if they're not currently async, I'm worried about introducing code that causes them to become async in the future, forgetting to update the tests, and then later running into some obscure failure related to it

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not a fan of having to add fakeAsync even though we might not need it. Presumably if we add some that is async in the future, we'd know what PR introduced it and we'd fix any failures before they make it into master.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's not really the way its worked out in the past. There have been a number of times where our CI was red due to async test failures and nobody really knew how to track down. If we preemptively make everything fakeAsync then its really obvious which test has the issue.

@crisbeto
Copy link
Member Author

I've switched everything over to fakeAsync @mmalerba.

@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 17, 2017
Moves all of the input tests away from the `async` zone either to the default one or to `fakeAsync`.
@jelbourn jelbourn merged commit 05084e9 into angular:master Nov 20, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants