Error Test for JSON-based APIs
Learn how to write our error test for testing JSON-based APIs.
We'll cover the following...
We'll cover the following...
It’s common to have the success tests before the error tests, but that doesn’t mean we have to write them in that order.
Defining an error test
We’re going to start with the simplest test for this endpoint: our error case. Let’s add the following test inside of the describe block in user_controller_test.exs:
Let’s go over some more important features of this test:
-
The test accepts a context from the setup block, in this case giving it a user and a
Plug.Connthat contains a header ...