laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Make JSON assertion failure diffs in feature tests more discernible #2531

Closed timraasveld closed 3 years ago

timraasveld commented 3 years ago

Right now, TestResponse::assertJson(Fragment) shows a colorless, single-line diff of the expected versus actual JSON. I would like to contribute a better method of diffing, that uses multiple lines and colors to make the difference more visually discernible.

Here is an example of how a Ruby testing framework does it. You can immediately see which JSON fields didn't match the expectation. image

Does this idea fit in the Laravel roadmap? If yes, I have a few questions about how to go about contributing this:

  1. Is it okay to use a small diffing library, or to optionally depend on system diff or git commands (and fall back on the current diff implementation if not present)? Or should I implement it from scratch?
  2. Can I just create a PR on the main repo?
martinbean commented 3 years ago

+1

I’ve definitely been bitten by this a few times in the past! So a much more visually-rich and obvious diff would be welcome!

themsaid commented 3 years ago

Feel free to submit a PR with your suggested changes 👍