Skip to content

Use exception helpers instead of try catch #425

Merged
astarinmymind merged 4 commits intodevelopfrom
use-exception-helpers
Mar 23, 2021
Merged

Use exception helpers instead of try catch #425
astarinmymind merged 4 commits intodevelopfrom
use-exception-helpers

Conversation

@astarinmymind
Copy link
Copy Markdown
Contributor

This PR adopts this pattern for async tests when testing exceptions:
await expect(yourFunction()).rejects.toThrow()

@astarinmymind astarinmymind requested a review from a team as a code owner March 22, 2021 19:32
Gudahtt
Gudahtt previously approved these changes Mar 22, 2021
Copy link
Copy Markdown
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

it('should timeout', async () => {
await expect(
util.safelyExecuteWithTimeout(() => {
return new Promise((res) => setTimeout(res, 800));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a blocker for this PR because it was already broken in this manner, but this isn't quite enough to test that this is working correctly.

For us to know the timeout was triggered, we'd have to ensure that something other than undefined would be called otherwise. e.g.

Suggested change
return new Promise((res) => setTimeout(res, 800));
return new Promise((resolve) => setTimeout(() => resolve('No timeout!'), 800));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Noted! I will fix this test in a different PR :)

@astarinmymind astarinmymind merged commit 18e016c into develop Mar 23, 2021
@astarinmymind astarinmymind deleted the use-exception-helpers branch March 23, 2021 03:44
Mrtenz pushed a commit that referenced this pull request Oct 16, 2025
Update dependencies that Socket warned about in #423

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?

Are there any issues or other links reviewers should consult to
understand this pull request better? For instance:

* Fixes #12345
* See: #67890
-->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Updates yarn.lock to bump several packages (e.g., cross-spawn 7.0.6,
form-data 3.0.4, get-intrinsic 1.3.1) and add required transitive deps
to address audits.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
a6eefaab549ac8b5980443e43b5c3a3b847682ab. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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