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] Track exceptions and display them on failed status checks for dx #38025

Merged
merged 7 commits into from
Jul 16, 2021

Conversation

taylorotwell
Copy link
Member

This feature is inspired by feedback from @jessarcher and my own poor experience with testing endpoints that throw unexpected exceptions.

This problem typically arises when asserting against the status of a test response and receiving a failed assertions indicating the expected status code did not match the actual status code of 500. You must then examine your logs to hopefully determine what the exception message was. Or, you can call $this->withoutExceptionHandling()->get(...) to disable exception handling for the test.

Ideally, Laravel would just show you the exception. This PR takes care of that by tracking exceptions while running unit tests and then displaying the exception failed status checks where the actual status code is 500.

image

image

@GrahamCampbell GrahamCampbell changed the title Track exceptions and display them on failed status checks for dx [8.x] Track exceptions and display them on failed status checks for dx Jul 15, 2021
@negoziator
Copy link

It's uncountable how many times I've wanted this.
Great job! 🎉

@deleugpn
Copy link
Contributor

👌

@rachids
Copy link

rachids commented Jul 15, 2021

To all those $this->withoutExceptionHandling() that hasn't been removed and managed to pass the code review: you're in danger.

Copy link
Member

@jessarcher jessarcher left a comment

Choose a reason for hiding this comment

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

This is a brilliant DX improvement and will save a lot of time and frustration! Thank you 😁

@jessarcher
Copy link
Member

In the spirit of removing the need to add temporary debugging code, I wonder whether there is also an opportunity to improve the output on an unexpected validation exception.

Currently I get this a fair bit:

image

Even without exception handling (which this PR removes the need for 😁), the output is no more helpful:

image

So I end up needing to add a temporary $response->dump() to see the actual validation errors.

If this sounds useful, I'm happy to have a go once this PR is merged. I'm thinking if it's a JSON request then it should show the errors as JSON, otherwise perhaps just a var_export().

@taylorotwell
Copy link
Member Author

@jessarcher sounds like a good idea

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