Cypress Training Advent Lesson Day 7
Let's call the API until it returns an item we have seen already
Let’s write another test that uses recursion. This test will call the backend API directly using the cy.request
command. If the backend returns a fruit we have already seen, we should print all saved fruits and finish the test. Please implement the test “Spec 16: Get the fruits from the test using the cy.request command” from the Cypress Network Testing Exercises course
Tip: stopping the test means we simply don’t call the recursive function again.
Bonus: presentation slides and video
A few weeks ago I have delivered the “Tips & Tricks for Writing Fast and Maintainable Front-End Tests” presentation at AllThingsOpen conference. The video is now public and you can watch the talk below.
My presentation slides are at https://slides.com/bahmutov/tips-tricks and you can find all my talks related to End-to-End testing inside MecariUS at https://slides.com/bahmutov/decks/mercari.
Previous lessons
Lessons marked with 📡 are from the Cypress Network Testing Exercises course. Lessons marked with 🔌 are from the Cypress Plugins course.
Day 1: 📡 “Spec 08: Import the JSON fixture directly into the spec”
Day 2: 📡 “Spec 14: Reloads the page until it sees the word Bananas"Cypress
Day 3: 🔌 “Lesson a3: Log the messages from the test to the terminal“
Day 4: 📡 “Spec 04: The application is showing the loading element“
Day 5: 📡 “Spec 11: Test how the application makes a network request every minute”
Day 6: 🔌 “Lesson a7: Re-run the tests when the source files change with cypress-watch-and-reload plugin“