Deciding an approach to make the end-to-end test pass
With that all said, how do we begin writing Vitest unit tests now that we have a Playwright test that defines what we want?
The Playwright test looks for the names Hercules
and Athena
. The test makes an assumption that these two people have their birthdays listed in the system and that the page at /birthdays
lists them. But how do we get them into the system in the first place?
In true TDD style, we can defer this decision and simply hardcode these two birthdays in the system. After all, the test doesn’t seem to care about how the data gets into the system, only about how it is presented.
We can come back to how the birthdays are added later. In fact, we’ll do this in Chapter 8, Creating Matchers to Simplify Tests. We can also make use of our Birthday
component from Chapter 2, Introducing the Red-Green-Refactor Workflow, to display each birthday in turn.
Therefore, what we need to do is the following:
...