-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor: use jasmine expectAsync instead of try/catch in tests #18535
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
refactor: use jasmine expectAsync instead of try/catch in tests #18535
Conversation
9cb859e
to
30eb1c5
Compare
@@ -156,6 +156,8 @@ | |||
}, | |||
"resolutions": { | |||
"dgeni-packages/typescript": "3.7.4", | |||
"@bazel/jasmine/jasmine": "3.5.0", | |||
"@bazel/jasmine/jasmine-core": "3.5.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are temporarily until @bazel/jasmine
has been updated to jasmine v3.5.0. I created a ticket for tracking: DEV-37, and also sent a PR upstream to update jasmine.
Currently tests that assert errors to be thrown/or not from asynchronous methods use `try/catch` in order to use `await`. We added a helper method for this in the private testing utilities. This one reduced the `try/catch` burden. That helper method has downsides though because it doesn't allow us to expect no error to be thrown. We should remove this method in favor of using jasmine's `expectAsync` function. This one gives us more flexibility and is also more "jamsine"-idiomatic.
30eb1c5
to
8b8c980
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Currently tests that assert errors to be thrown/or not from asynchronous methods use `try/catch` in order to use `await`. We added a helper method for this in the private testing utilities. This one reduced the `try/catch` burden. That helper method has downsides though because it doesn't allow us to expect no error to be thrown. We should remove this method in favor of using jasmine's `expectAsync` function. This one gives us more flexibility and is also more "jamsine"-idiomatic. (cherry picked from commit 19de0bd)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Currently tests that assert errors to be thrown/or not from
asynchronous methods use
try/catch
in order to useawait
.We added a helper method for this in the private testing utilities. This
one reduced the
try/catch
burden. That helper method has downsidesthough because it doesn't allow us to expect no error to be thrown.
We should remove this method in favor of using jasmine's
expectAsync
function. This one gives us more flexibility and is also more
"jamsine"-idiomatic.