Cypress Training Advent Lesson Day 22
Learn how to keep the server response around to be saved to a file later 💾
What can you do when you intercept a network call? Can you save the server response to a file? Not immediately, no. You cannot call Cypress test commands from inside the cy.intercept
callbacks (read “Cypress Cannot Add Out-Of-Band Commands” blog post).
// WILL NOT WORK, JUST FOR DEMO
cy.intercept('GET', '/fruit', (req) => {
req.continue((res) => {
cy.writeFile('response.json', response)
})
}).as('fruit')
...
cy.wait('@fruit')
What can you do instead if you want to write the received response to a file? Try solving the lesson “Bonus 12: Save the intercepted network response using cy.writeFile“ to find out. There are two solutions!
The Course Discount Code
I hope you are enjoying this Cypress Training Advent Course. I am enjoying creating new lessons for it. Often I add new bonus lessons to answer questions from the current course students (both the Network Testing and Cypress Plugins students can ask questions in our Discord channel). The courses have grown over the months:
The networking course has 94 lessons
The plugins course has 72 lessons
For anyone enjoying these lessons and who wants to continue learning, I have created a 10% discount. Use the coupon ADVENT2022 before the end of the year. Next year I plan to finish the plugins course bringing the total number of lessons to 100, and increase the price of each course.
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“
Day 7: 📡 “Spec 16: Get the fruits from the test using the cy.request command“
Day 8: 📡 “Spec 19: Intercept a specific request by matching the header”
Day 9: 🔌 “Lesson b1: Slow down the test commands using cypress-slow-down“
Day 10: 📡 “Spec 21: Modify the server response using cy.intercept”
Day 11: 📡 “Spec 22: Using cy.wait vs cy.get to access the intercepted request”
Day 12: 🔌 “Lesson l1: Confirm the attribute of the last item”
Day 13: 📡 “Spec 27: Simulate the server network error”
Day 14: 📡 “Spec 30: Handles test flake using the test retries”
Day 15: 🔌 “Lesson e3: Validate URL search parameters”
Day 16: 📡 “Bonus 1: The server returns zero or more fruits“
Day 17: 📡 “Bonus 13: The req.reply and req.continue methods”
Day 18: 🔌 “Lesson f3: Show a beautiful record of every API call”
Day 19: 📡 “Bonus 17: Check the array yielded by the cy.request command”
Day 20: 📡 “Bonus 18: Wait for multiple requests at once”
Day 21: 🔌 “Lesson j1: Create and cache an item”
If i purchased the course of cypress plugins-
1) how many days i will have access to videos and files and other doucments
2) is it online class or recorded sessions
3) will i get any support if i got struck during practice ?
4) do we have any course coupon code like Advant 2022 which i missed
please help me with above information so that i will
plan a head to join CYpress plugins course