How to test @BrowserCallable

I have a customer that wants to use Hilla. Now the question came up how to test the service layer that uses @BrowserCallable.

How do you do that if you want to test the HTTP calls too not only the service layer?

My (and likely yours also?) mental model would be the same as for a Spring @RestController? Which would make the question like: Does @MockMvc work with Hilla or is there a similar mock tool available for the endpoints? Maybe MockMvc with POST (+headers+cookies) does actually work, but never done that.

I think doing a SpringBootTest and injecting the BrowserCallable would do the same.

Another question is: would it be possible to create fullstack tests like with the Browserless tests that test the React component with a backend call?

The premise of Hilla os that you should not have need to test them explicitly. This Hilla’s internal implemention that is covered by Hilla’s own unit and integration tests. Thus you should be able to trust it in the same way, that in the Flow side you do not need to test the communications layer either.

2 Likes