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

[8.x] Show a pretty diff for assertExactJson() #38655

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

jessarcher
Copy link
Member

When using assertExactJson() with a large payload, it can be incredibly difficult to compare the "expected" and "actual" values to see what caused the failure.

This PR pretty-prints the JSON before asserting, which allows PHPUnit to show the specific lines that didn't match, with a few lines of context.

Before
image

After
image

I couldn't find a way to test this new behaviour which didn't just seem to be testing PHPUnit itself.

@timacdonald
Copy link
Member

Can you please just push this one straight to main and by-pass the PR process, thanks.

-- A developer very, very keen on this change.

@michaeldyrynda
Copy link
Contributor

michaeldyrynda commented Sep 3, 2021

I feel like this is something that could be part of Collision. What do you think @nunomaduro?

@dillingham
Copy link
Contributor

dillingham commented Sep 3, 2021

A (slightly) related papercut: when expected is empty and actual isn't (or vice versa), could just say that.. in most cases don't need the payload. In every other case, the pretty print is awesome.. thank you for PRing it.

@taylorotwell taylorotwell merged commit abab1c8 into laravel:8.x Sep 3, 2021
victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
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.

6 participants