You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Saloon::fake([
//This is for searching /users, therefore GET
'*' => MockResponse::make(
[
"items" => [],
"meta" => [
"pagination" => [
"current_page" => 1,
"next_page" => null,
"prev_page" => 0,
"total_pages" => 1,
"total_items" => 0,
"entries_info" => "1-10 of 10"
]
]
]
),
//This is for creation, therefore POST
'users' => MockResponse::make([
"id" => 123456789
]
),
]);
Therefore, is there any way to 'tell' Saloon which 'users' endpoint to use for GET and which to use for POST?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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