Skip to content

chore: Use idiomatic Jest patterns to assert exceptions#1909

Merged
SethFalco merged 1 commit intosvg:mainfrom
jdufresne:tothrow
Dec 28, 2023
Merged

chore: Use idiomatic Jest patterns to assert exceptions#1909
SethFalco merged 1 commit intosvg:mainfrom
jdufresne:tothrow

Conversation

@jdufresne
Copy link
Copy Markdown
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
Comment thread lib/svgo.test.js
@SethFalco SethFalco merged commit db05c57 into svg:main Dec 28, 2023
@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