Calling our endpoint

For the first call to our server, we have broken it down into three steps:

  1. When the client creates a POST request to /users
  2. And attaches a generic empty payload
  3. And sends the request

In the first step, we will create a new request object and save it as a file-scoped variable, making it available to be accessed by subsequent steps. In the second, we will attach an empty payload to the request; however, this is already the default behavior of superagent, so we can simply return from the function without doing anything. In the third step, we will send the request and save the response in another variable.

You should now update the start of your spec/cucumber/steps/index.js file to the following snippet:

import superagent ...

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.