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

chore: Use idiomatic Jest patterns to assert exceptions #1909

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

jdufresne
Copy link
Contributor

Avoid unnecessary assertions such as expect(true).toBe(false). Instead, assert the exception using the toThrow() matcher. Where that is insufficient, use expect.assertions(). Unwrap exceptions in promises using expect.rejects.

These patterns are documented at:

Avoid unnecessary assertions such as `expect(true).toBe(false)`.
Instead, assert the exception using the `toThrow()` matcher. Where that
is insufficient, use `expect.assertions()`. Unwrap exceptions in
promises using `expect.rejects`.

These patterns are documented at:

- https://jestjs.io/docs/expect#tothrowerror
- https://jestjs.io/docs/tutorial-async#rejects
- https://jestjs.io/docs/expect#expectassertionsnumber
@jdufresne jdufresne changed the title Use idiomatic Jest patterns to assert exceptions chore: Use idiomatic Jest patterns to assert exceptions Dec 27, 2023
@SethFalco SethFalco merged commit db05c57 into svg:main Dec 28, 2023
10 checks passed
@jdufresne jdufresne deleted the tothrow branch December 28, 2023 19:10
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.

3 participants