I am trying to write some tests for a JSON Api. If something in the action raises an error, I would like a JSON error to be returned to my test.
Action
def get(conn, params) do
1=2
end
My test
test "Get always returns 500 - internal server error", %{conn: conn} do
conn = get(conn, Routes.my_path(conn, :get_it)
assert json_response(conn, 500)["errors"] != %{}
end
test raises an error: ‘no mach of right hand…’ Instead of it raising an error, I would like to capture a 500 error similar to what the client will get.