Replies: 2 comments
-
Perhaps you can pass your Request class directly instead of a string and then check what you need to check? use Saloon\Enums\Method;
Saloon::fake([
UserRequest::class => function (PendingRequest $pendingRequest) {
return match ($pendingRequest->getMethod()) {
Method::GET => MockResponse::make(body: '', status: 200),
Method::POST => MockResponse::make(body: '', status: 200),
};
},
]); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Or make a separate request class for each |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm working with an API which has a /users endpoint that I wish to test with. The issue is that to search for users; I use GET but to create, I need to POST.
However, because wildcards are not supported inside a URL, I can't seem to get Saloon to work out which MockResponse to use, so it ends up failing as the wild card is always returned.
Ideally, the first should be something like /users?query=* but that doesn't seem to work.
Therefore, is there any way to 'tell' Saloon which 'users' endpoint to use for GET and which to use for POST?
Beta Was this translation helpful? Give feedback.
All reactions