How to Handle Non-Cypress Async Promises using .then command? | Cypress Tutorial | Part V
This video is a part of our Cypress Testing Tutorial series. In this video, Chris DeSilva (@desilvadev) explains how to manage Non-Cypress Async Promises. Also, you will get to know when to use the “.then” method in Cypress, which is built-in Cypress to explicitly handle Non Cypress Promises.
00:00 Introduction of Non-Cypress Async Promises
00:44 Learning goals
03:07 Adding .then() to utilize Non Cypress Commands
09:40 Recap
10:41 Conclusion of Session
Introduction to Cypress's Synchronous and Asynchronous Features: The video begins by recapping Cypress's handling of synchronous and asynchronous operations, emphasizing the difference between Cypress commands (which queue and execute in order) and non-Cypress commands (which do not follow the Cypress execution queue).
Handling Non-Cypress Async Promises: It delves into strategies for managing asynchronous promises in Cypress that are not inherently part of the Cypress command queue. This includes examples of using console logs and network requests that are executed outside of the Cypress command queue.
Using the .then() Method in Cypress: A significant portion of the video focuses on the .then() method provided by Cypress to handle non-Cypress promises. This method allows for the sequential execution of Cypress commands followed by non-Cypress commands, ensuring that asynchronous operations complete in the expected order.
Practical Examples and Demonstrations: The presenter provides practical coding examples to demonstrate how to use the .then() method to handle asynchronous operations, including logging and fetching data from an API (using the SpaceX API as an example).
Advanced Use Cases for .then() Method: Further exploration of the .then() method showcases its versatility in integrating non-Cypress asynchronous operations within the Cypress test workflow, such as making network requests after certain Cypress commands have executed.
Conclusion and Further Learning: The video concludes with a summary of the key points covered and a teaser for upcoming content focusing on building more complex tests with Cypress, including writing assertions to verify elements' presence, values, and properties.
Selenium vs Cypress – Which Is Better in 2021?
What is Cypress Test Automation Framework