Test Execution with CLI | Bondar Academy
Course: Cypress UI Testing with JavaScript
Module: Cypress Hands-On Overview
Instructor: Artem Bondar
Lesson Summary
In this lesson, we learn how to run tests using the Command Line Interface (CLI) without the Cypress runner. Here’s a summary of the key points: Running Tests Open the terminal in Visual Studio Code . Use the command: npx cypress run to execute all tests in the E2E folder in headless mode . Execution results will display in the command line, showing the number of tests passed and failed. Handling Test Failures After a test fails, Cypress generates screenshots. For example, a failure occurred due to a missing base URL property in the configuration file. Running Specific Tests To run a specific test, use: npx cypress run --spec followed by the relative path to the spec file. To run tests in headed mode , add the flag: --headed . To specify a browser, use: --browser followed by the browser name (e.g., chrome or firefox ). Additional Options For more command options, refer to the Cypress documentation under the command line section. Some useful flags include: --parallel for running tests in parallel (Cypress Cloud required). --no-exit to keep the browser open after test execution. This lesson provides a foundational understanding of running Cypress tests via the command line, which is particularly useful for continuous integration environments.