...

/

Testing our JavaScript Functionality

Testing our JavaScript Functionality

Learn to apply testing of Javascript functionality.

Testing the functionality

Now that we have application-level functionality in JavaScript code, we are going to need to put tests in place to ensure that the function not only works as intended but continues to work as we make changes to the application.

Testing this functionality involves a lot of steps. We have to visit the store, select an item, add that item to the cart, click checkout, fill in a few fields, and select a payment type. From a testing perspective, we are also going to need both a Rails server and a browser.

To accomplish this, Rails makes use of a version of the popular Google Chrome web browser named ChromeDriver, which has been augmented to include programming interfaces to enable automation, and Capybara, which is a tool that drives this automation.

Tests that pull together a complete and integrated version of the software are called system tests, which is exactly what we will be doing. We will be testing a full end-to-end scenario with a web browser, web ...