Checking for required fields

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 says "Payload must contain at least the email and password fields"  Examples:  | missingFields |  | email         | | password ...

Get Building Enterprise JavaScript Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.