Writing More Cypress Tests
Let’s return to our Cypress tests. In the last chapter, we wrote a test that shows that our “add favorite” functionality works. Now we want to show that our “remove favorite” functionality also works.
We could just add more lines to the existing test to continue that scenario with a removal of favorite functionality. That’s a reasonable thing to do in some circumstances. However, longer tests like that tend to be more brittle, and a failing test gives you less information because the failure might be anywhere along the sequence of the test.
But in order to get a test to a state where we can remove a favorite, we kind of have to go through all those same steps: log in a user and add a favorite. Ideally, we’d be able ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access