Cypress Utilities, APIs, and Troubleshooting
Let's look at Cypress utilities, API, and troubleshooting in this lesson.
We'll cover the following...
Cypress also has a command-line tool that allows you to run Cypress from a terminal or from a command line in a continuous integration tool. In our environment, we start that tool with rake cypress:run
. Doing so will run the tests against the Electron JS runtime by default.
If you run this command, you’ll get output directly In your terminal. You’ll get a line for each individual test with a time amount (for example, ✓ marks a group of tickets sold on click (487ms)
), you’ll get a summary table for each file, and you’ll get a final summary table that gives the time and test count for each file.
You will also get files in tmp/cypress_videos
, one for each test file, that show a video capture of the browser for each test in the file. A failing test adds a screenshot of the failure into the folder tmp/cypress_screenshots
.
This command is probably mostly going to be run on a continuous integration server. In actual development, you may want the interactive test runner and access to the browser tools.
Troubleshooting
Sometimes things just don’t work the way you expect, either when testing your code in Cypress or when just running it in the browser. Browsers have a lot of different tools to allow you to explore what is happening. We’ll take a look at those tools first, then look at debugging Cypress tests in the Cypress test runner. We’ll end by taking a quick peek at a browser extension to troubleshoot React components.
Using the console log
If you are me, logging has always been a big part of your debugging flow. Visual ...