Red. Green. Refactor. Now that all tests pass, it's a good time to refactor our code.
Our application code, although slightly repetitive, is easy to follow and read; therefore, we don't need to refactor it for now. There are, however, some improvements we can make to our test code. For example, we are hardcoding the Create User payload into our tests; it'll be better if we abstract that into a function that generates the payload when called.
We are going to create a new spec/cucumber/steps/utils.js file to house our utility/support code. Add the following into the utils.js file:
function getValidPayload(type) { const lowercaseType = type.toLowerCase(); switch (lowercaseType) { case 'create user': return { ...