What this book covers
Chapter 1, Installing and Setting Up Cypress, takes you through the essentials of getting started with Cypress, including the installation of the Cypress package, the default configurations, and the customization of settings. In this chapter, you will learn about how Cypress works, what modules it requires to run, the test file naming recommendations, and how to get started with using Cypress. Understanding how Cypress works will ensure that you are able to grasp the internal workings of Cypress and will be able to install and set up the subsequent projects on your own with a full understanding of the Cypress framework's structure.
Chapter 2, Differences between Selenium WebDriver and Cypress, is where we will explore how Cypress is different from the Selenium WebDriver and highlight some of the pros and the cons of choosing Cypress to run end-to-end tests. In this chapter, we will also explore elements that make Cypress more suitable to testing than Selenium and how users can extend its functionality.
Chapter 3, Working with Cypress Command-Line Tools, exposes you to the different Cypress commands that you can use to execute Cypress commands. The chapter will explain how to run the commands and also how to debug the application using Cypress commands.
Chapter 4, Writing Your First Test, will see you write your first test using Cypress. We will start with a passing test to check that everything works correctly, then move on to a failing test, and then we'll see how Cypress behaves and how the auto-reload feature works. In the second section of this chapter, we will focus on more advanced scenarios of getting you up to speed with how to properly write Cypress tests.
Chapter 5, Debugging Cypress Tests, dives into the different kinds of tools that Cypress includes to aid in debugging applications. Using Cypress' debugging tools, you will learn how to travel back to the snapshot of each command, see different page events that happened during execution, and visualize different commands and the times when elements were hidden and found. You will also learn how you can step forward and backward between command snapshots and pause and step through command snapshots in an iterative manner.
Chapter 6, Writing Cypress Tests Using TDD Approach, introduces you to Test-Driven Development (TDD) concepts and how you can apply them to writing Cypress tests. You will learn how to write tests using a TDD approach and also dive deep into how you can practically apply TDD in an application that is yet to be developed.
Chapter 7, Understanding Element Interaction in Cypress, covers how to interact with various elements of the DOM. The chapter will also teach you how to interact with animations, how to hover over elements, and how to check whether elements are disabled. By the end of this chapter, you will be comfortable with navigating through the DOM elements and writing meaningful tests for elements.Â
Chapter 8, Understanding Variables and Aliases in Cypress, explores how to deal with asynchronous commands through the use of aliases. We will also identify ways in which we can simplify our tests by using aliases. Finally, we will identify how to use aliases with routes and requests.
Chapter 9, Advanced Uses of Cypress Test Runner, looks at how to utilize the Cypress test runner to write better tests. Our focus will be on the instrument panel and the selector playground. We will learn how to use the instrument panel to understand the concepts of spying and stubbing and how Cypress interprets them.
Chapter 10, Exercise – Navigation and Network Requests, exposes you to practical examples and exercises aimed at practicing how to use and make navigation of network requests. The exercise will also combine concepts such as aliasing and use of variables to ensure that you are able to chain the different concepts learned about in the second section of the book.
Chapter 11, Exercise – Stubbing and Spying XHR Requests, looks at understanding what XHR requests are and how Cypress can assist in stubbing requests that take too long or that are complicated to receive responses from. Cypress stubbing will be important to ensuring that implemented tests are not flaky and that we can have custom responses instead of waiting for server responses from a request.
Chapter 12, Visual Testing in Cypress, covers how visual testing works in Cypress. We will explore what visual testing is, different types of testing, and how critical visual testing is to the modern web. We will also look at viewports and how they influence the process of visual testing and finally look at visual testing automated tools such as Applitools and Percy that we can use to carry out visual validation.