Implementing step definitions
To test our API server, we would need to run the server itself and send HTTP requests to it. There are many ways to send requests in Node.js:
- Using the
request
method provided by Node's nativehttp
module. - Using the new Fetch Web API syntax:
fetch
is an improvement on the traditionalÂXMLHttpRequest
used to make AJAX (Asynchronous JavaScript And XML) requests from the client. We can use polyfills, such asisomorphic-fetch
 (https://www.npmjs.com/package/isomorphic-fetch), which will allow us to use the same syntax on the server. - Using a library, such asÂ
request
 (https://www.npmjs.com/package/request),Âsuperagent
 (npmjs.com/package/superagent),Âaxios
 (npmjs.com/package/axios), and many more.
Using the native http
module allows us to be as expressive as possible because it works at the lowest-level API layer; however, this also means the code is likely to be verbose. Using the Fetch API might provide a simpler syntax, but it will still have a lot of boilerplate code...