How can I test for an empty JSON response from a rest endpoint. I was hoping for something along the lines:
ResultActions actions = mockMvc.perform(..);
actions.andExpect(jsonPath("$", empty()));
obviously this fails as {}
is not exactly empty.
Any advice?
Try this one:
ResultActions actions = mockMvc.perform(..);
actions.andExpect(content().string("[]"));
This worked for me:
ResultActions actions = mockMvc.perform(..);
actions.andExpect(content().string(""));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With