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

Replace callbacks with async/await in tests #994

Merged
merged 7 commits into from
Sep 22, 2022
Merged

Replace callbacks with async/await in tests #994

merged 7 commits into from
Sep 22, 2022

Conversation

afcapel
Copy link
Contributor

@afcapel afcapel commented Sep 22, 2022

Avoids deep nesting, especially when some async events, like inputs in tests, are performed in sequence.

The nesting was never very readable, but since we moved away from coffeescript it became even messier with the added closing curly brackets.

Note that I've replaced most calls to defer(callback) with await nextFrame(). However, defer is implemented as a 1ms delay while nextFrame is just calling requestAnimationFrame. They should be roughly equivalent but there might be slight differences that can make the some tests flaky. I suggest patching those tests adjusting the delay if we see they are flaky.

To avoid flaky tests in CI.
@afcapel afcapel merged commit fe09966 into v2 Sep 22, 2022
@afcapel afcapel deleted the async-tests branch September 22, 2022 13:32
Copy link
Contributor

@kevinmcconnell kevinmcconnell left a comment

Choose a reason for hiding this comment

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

This looks great! A big improvement for readability.

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.

2 participants