Skip to content

Conversation

@LeTamanoir
Copy link
Contributor

When testing code that uses Http::pool via the Http::fake and Http::preventStrayRequests the error won't be propagated correctly, for example if you forget to fake a path you will get this kind of error:

Illuminate\Http\Client\PendingRequest::{closure:Illuminate\Http\Client\PendingRequest::makePromise():994}(): Argument #1 ($e) must be of type OutOfBoundsException|GuzzleHttp\Exception\TransferException, RuntimeException given, called in /[REDACTED]/vendor/guzzlehttp/promises/src/RejectedPromise.php on line 49

with the changes I propose you should get the following:

Attempted request to [your/route/...] without a matching fake.

@LeTamanoir LeTamanoir marked this pull request as draft May 9, 2025 11:19
@LeTamanoir LeTamanoir marked this pull request as ready for review May 9, 2025 11:50
@LeTamanoir
Copy link
Contributor Author

I was not sure if I should have stayed with the RuntimeException + adding a regex check for the error message content in the PendingRequest callback.

Changing the exception class might be breaking for some strange code out there in the wild haha,
but considering it still inherits RuntimeException and Http::fake is only meant for testing I guess it's fine...

WDYT guys ?

@taylorotwell taylorotwell merged commit 76cee6b into laravel:12.x May 9, 2025
58 checks passed
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