Skip to content

fix(payments): replace assertion errors#19921

Merged
StaberindeZA merged 1 commit intomainfrom
pay-3392-replace-assertion-errors
Jan 22, 2026
Merged

fix(payments): replace assertion errors#19921
StaberindeZA merged 1 commit intomainfrom
pay-3392-replace-assertion-errors

Conversation

@StaberindeZA
Copy link
Copy Markdown
Contributor

Because

  • Ensure that assertion errors throw a unique error providing additional information related to the error.

This pull request

  • Where necessary update assertion errors to throw a unique error.
  • Add tests for all assertion errors.

Issue that this pull request solves

Closes: PAY-3392

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Any other information that is important to this pull request.

Because:

- Ensure that assertion errors throw a unique error providing additional
  information related to the error.

This commit:

- Where necessary update assertion errors to throw a unique error.
- Add tests for all assertion errors.

Closes #PAY-3392
@StaberindeZA StaberindeZA requested a review from a team as a code owner January 22, 2026 16:26
Copy link
Copy Markdown
Contributor Author

@StaberindeZA StaberindeZA left a comment

Choose a reason for hiding this comment

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

note: I opted to keep asserts in cart.manager as is, since the cart.manager methods wrap each error with a CartManager error already.

Comment on lines +2108 to +2110
await expect(cartService.getCart(mockCart.id)).rejects.toThrow(
/GetCartFromPriceMissingError/
);
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.

note: There's a known issue with assert and jest when adding a custom error message to your assert, jest still throws it as an AssertionError. Because of that, the way these tests check that the correct Error is thrown, is by checking if the Error name is included in the error message.

@StaberindeZA StaberindeZA merged commit 0eda038 into main Jan 22, 2026
21 checks passed
@StaberindeZA StaberindeZA deleted the pay-3392-replace-assertion-errors branch January 22, 2026 17:47
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