Search⌘ K
AI Features

Introduction to Testing with Cypress

Explore how to implement end-to-end testing in Rails applications using Cypress. Understand Cypress advantages, installation steps, and how it improves testing reliability and debugging compared to traditional tools.

Introduction

Testing JavaScript code is notoriously difficult. Because JavaScript typically runs in a browser environment and interacts closely with the DOM and user behavior, it is often challenging to write valuable tests that are also consistent and fast.

When testing JavaScript, it’s helpful to think about what we want to get out of the testing. In this chapter, we’ll focus on two goals:

  • Using tests to validate that the code is doing what we think it is

  • Using tests to help development by allowing us to rapidly run situations that would take a long time to recreate manually

While a wide variety of testing tools are available in JavaScript, in this chapter our focus is on end-to-end testing with Cypress, a tool that simulates interactions with our Rails server and the browser.

Why focus on just one tool? The various tools overlap in functionality but ...