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
So I'm not sure if there is a way to do this or not, but in your examples, you have a success endpoint and a failure endpoint. In real life, there would be only 1 endpoint that returned success or failure.
So in my example, a user logs in and the body would be something like {"email":"[email protected]","password":"12345"} and they would get a token returned.
Which is working fine. But what if I wanted to test a case where the login credentials are bad and therefore it returns an error? This way I can test what the UI looks like after the error response. Obviously, I would need to do this from the same endpoint.
So I would want setResponseCode to be conditional by somehow checking the request body
The text was updated successfully, but these errors were encountered:
So I'm not sure if there is a way to do this or not, but in your examples, you have a success endpoint and a failure endpoint. In real life, there would be only 1 endpoint that returned success or failure.
So in my example, a user logs in and the body would be something like {"email":"[email protected]","password":"12345"} and they would get a token returned.
So my mock looks like this:
Which is working fine. But what if I wanted to test a case where the login credentials are bad and therefore it returns an error? This way I can test what the UI looks like after the error response. Obviously, I would need to do this from the same endpoint.
So I would want
setResponseCode
to be conditional by somehow checking the request bodyThe text was updated successfully, but these errors were encountered: