So far, we've been writing tests that ensure our request is valid and well-formed; in other words, making sure they are syntactically correct. Next, we are going to shift our focus to writing test cases that look at the payload object itself, ensuring that the payload has the correct structure and that it is semantically correct.
In our requirements, we specified that in order to create a user account, the client must provide at least the email
and password
fields. So, let's write a test for this.
In our spec/cucumber/features/users/create/main.feature
file, add the following scenario outline:
Scenario Outline: Bad Request Payload When the client creates a POST request to /users And attaches a Create User payload which is missing the <missingFields> field And sends the request Then our API should respond with a 400 HTTP status code And the payload of the response should be a JSON object And contains a message property which...