Skip to content

test: improve assertion messages #1572

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

Merged
merged 1 commit into from
Apr 30, 2025
Merged

test: improve assertion messages #1572

merged 1 commit into from
Apr 30, 2025

Conversation

kuhe
Copy link
Contributor

@kuhe kuhe commented Apr 30, 2025

Now that we're using vitest (also would've been possible through a jest extension), we can do something about

expected undefined to be defined

in generated protocol tests, which is a very unhelpful assertion message.

Now it will say, for example:

The output field httpDateOnTarget should have been defined in {
  "$metadata": {
    "httpStatusCode": 200,
    "attempts": 1,
    "totalRetryDelay": 0
  }
}: expected undefined to be defined

@kuhe kuhe requested a review from a team as a code owner April 30, 2025 13:37

expect(r.headers["accept"]).toBeDefined();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

an isDefined assertion is unnecessary when preceding a match to an exact value.

@kuhe kuhe force-pushed the test/messages branch 2 times, most recently from be377eb to 16b4adc Compare April 30, 2025 13:44
@kuhe kuhe merged commit 881e4fe into smithy-lang:main Apr 30, 2025
10 checks passed
@kuhe kuhe deleted the test/messages branch April 30, 2025 20:36
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