Let’s test the case where we try to register two users of the same username. We’ll first register a user, and then we’ll attempt to register a second user with the same username and assert on the error message. We’ll use toMatchInlineSnapshot on the error that’s returned and Jest will serialize that like a champ.


Use Snapshots to Assert on Server Error Responses