πββοΈ Working with the Cypress Test Runner
The Cypress Test Runner is the interface where you execute and monitor test cases. Follow these steps to use it effectively:
π Homepage
- When you open Cypress, you will see a Welcome to Cypress screen
- You will find two options:
- β E2E Testing (this is what we will be using; click this)
- β Component Testing (ignore this)
- β³ After clicking E2E Testing, Cypress will initialize the configuration. Let it finish loading
π Choosing a Browser
- π Cypress will detect all installed browsers on your system
- β‘It is highly recommended to choose Electron because it is built into Cypress, optimized for speed and stability
- β After selecting a browser, click Start E2E Testing
π¨ If Cypress crashes during execution, try switching to a different browser (e.g., Chrome, Edge, or Firefox) to resolve compatibility issues.
π₯οΈ Test Runner Interface
Once Cypress launches the Test Runner, you will see the following sections:
- π Tabs on the Left Side
- Specs (most important; this is where you will interact with test files).
- Runs (used for monitoring past test executions, but not needed for our use case).
- Debug (for advanced debugging tools).
- Settings (configuration options for Cypress).
- βΆοΈ Running a Test Case
- Under the Specs tab, you will see a list of test files.
β Click on any test file, and it will automatically start running.
-
π Switching Test Cases β Option 1: If you are inside a running test file, look at the left side before the Command Log. You will see the Specs folder section
β If it does not appear, click βSpecsβ (hovering over it should say βExpand Specs Listβ)
β Click on any test you wish to switch to
β Option 2: Click the Specs icon on the left navigation tab to return to the Specs tab, where you can select another test
-
πββοΈUnderstanding the Test Execution β Command Log (Left Side): Displays a step-by-step log of Cypress commands being executed. The contents of this log will be explained further in the Working with Test Cases section
β Test Status Menu (Above the Command Log):
- β Shows a β check mark (indicating successful test cases)
- β Shows a β X mark (indicating failed test cases)
- To the right of these, there is a βΉ Stop Button to halt the test execution
- If a test is stopped, a π Restart Button will appear to rerun the test
-
π₯οΈ App Preview (Right Side)
β This section displays a live preview of the test execution
β It simulates a real browser environment, allowing you to see interactions in real-time
β Any UI changes, clicks, or navigation actions performed by the test script will be reflected here
-
β Closing the Test Runner β Once you are done running tests, you can close the Cypress Test Runner:
β Use Ctrl + C in the terminal of Visual Studio Code, or simply close the Test Runner window by clicking the Close button in the top-right corner of the window