Skip to content

Conversation

@zainab-ali
Copy link
Contributor

@zainab-ali zainab-ali commented Nov 3, 2025

The expect.same and expect.eql methods have expected as their first parameter and obtained as their second.

expected and obtained are printed in the diff report in the failure message, but it's not obvious which parameter is which. To complicate things further, we use found as the parameter name in code, but obtained as the name in the failure message.

This PR improves the failure message to print in expect.same(expected, found). This should help users correlate the diff report to their code.

Before

image

After

image

@zainab-ali zainab-ali marked this pull request as draft November 4, 2025 10:41
@zainab-ali zainab-ali force-pushed the expect-same-failure-message branch 4 times, most recently from 9ae6d2c to 8ad0fcb Compare November 4, 2025 14:51
@zainab-ali zainab-ali force-pushed the expect-same-failure-message branch from 8ad0fcb to 3fc5b97 Compare November 4, 2025 14:54
@zainab-ali zainab-ali marked this pull request as ready for review November 4, 2025 15:12
loc: SourceLocation): Expectations = {
comparisonA.diff(expected, found) match {
case Comparison.Result.Success => Expectations(Validated.validNel(()))
case Comparison.Result.Failure(report) =>
Copy link
Contributor Author

@zainab-ali zainab-ali Nov 4, 2025

Choose a reason for hiding this comment

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

One problem with printing - expected and + found is that we assume the Comparison instance will respect the ANSI escape codes and + / - signs in the diff.

I think we can follow this up with some guidance on defining a Comparison.

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.

1 participant