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
Hi! I would like to assert on the received request body of a mock, but can't figure out how to acheive this.
To illustrate, let's say that I want to verify that a specific mock has received a request body that matches:
{
"foo": "bar"
}
I tried to do this with Matchers:
let expected_body = json!({"foo":"bar"});
wiremock::Mock::given(method("POST")).and(wiremock::matchers::path("/foo")).and(body_json(expected_body));
, but it seems that the mock now simply returns 404 if the body doesn't match. This does fail the test, but it fails it in a very subtle way. I would like for my tests to fail more explicitly with a message like "Mock received incorrect body ..." from assert_eq!.
I tried creating my custom Matcher that asserts on the body, but then I realized that since the mock runs in a totally separate process from the tests, this will just crash the mock server, which fails the test in an arguably even more subtle way.
I could check MockServer::received_requests, but this returns all requests for the entire test, which means that I have to somehow figure out which request was received by which mock.
Is there a better way to acheive this that I'm missing?
The text was updated successfully, but these errors were encountered:
Hi! I would like to assert on the received request body of a mock, but can't figure out how to acheive this.
To illustrate, let's say that I want to verify that a specific mock has received a request body that matches:
I tried to do this with Matchers:
, but it seems that the mock now simply returns 404 if the body doesn't match. This does fail the test, but it fails it in a very subtle way. I would like for my tests to fail more explicitly with a message like "Mock received incorrect body ..." from
assert_eq!
.I tried creating my custom Matcher that asserts on the body, but then I realized that since the mock runs in a totally separate process from the tests, this will just crash the mock server, which fails the test in an arguably even more subtle way.
I could check
MockServer::received_requests
, but this returns all requests for the entire test, which means that I have to somehow figure out which request was received by which mock.Is there a better way to acheive this that I'm missing?
The text was updated successfully, but these errors were encountered: