When using mockito's matchbody method to match requests, when a request is received that is not a good match, a serde::json::error::Error is thrown. This makes troubleshooting the test case difficult, as information on which requests the mock did receive are not exposed at any point.
Example:
#[async_std::test]
async fn test_demonstate_mockito_json_error_eof() {
let client = SomeApiClient::new(&mockito::server_url());
let mock = mock("POST", "/")
.match_body(Matcher::PartialJson(json!({
"someFlag": true,
})))
.with_status(200);
// send_request forwards the body json
let result = client
.send_request(json!({
"someFlag": false,
}))
.await
.expect("Received some unexpected error"); // panic here with EOF error
mock.assert() // never reached
}
When using mockito's
matchbody
method to match requests, when a request is received that is not a good match, aserde::json::error::Error
is thrown. This makes troubleshooting the test case difficult, as information on which requests the mock did receive are not exposed at any point.Example: