Implementing the step definitions
The final piece of the puzzle is the Given, When, and Then functions for matching feature steps with their implementations.
Checking your work as you go along
In this section we will speed through the definition, but make sure you verify each step is working by running Cucumber (with the npx @cucumber/cucumber command) after you’ve implemented each function.
Let’s do it!
- Create another new directory,
features/support, and create a file namedfeatures/support/steps.mjs, which starts with the following imports:import { Given, When, Then } from '@cucumber/cucumber'; - Then implement the first
Givenstep from our feature file. This one calls into the API using thethis.request.postfunction from Playwright. Note the use offailOnStatusCode, which makes sure that Cucumber fails the test if we don’t get a200 OKresponse back:Given( 'An existing birthday...