0
0
Cypresstesting~10 mins

Cypress CLI execution - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test runs a simple Cypress test using the CLI. It opens the browser, visits a webpage, checks for a visible element, and verifies the page title.

Test Code - Cypress
Cypress
describe('Cypress CLI execution test', () => {
  it('Visits example.cypress.io and checks title and element', () => {
    cy.visit('https://example.cypress.io')
    cy.get('h1').should('be.visible')
    cy.title().should('include', 'Kitchen Sink')
  })
})
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts via Cypress CLI command 'npx cypress run'Cypress test runner initializes and opens Electron browser-PASS
2Browser opens and navigates to 'https://example.cypress.io'Browser displays the example Cypress Kitchen Sink page-PASS
3Finds the <h1> element on the page using 'cy.get('h1')'The <h1> element is present and visible on the pageCheck that the <h1> element is visiblePASS
4Checks the page title includes 'Kitchen Sink' using 'cy.title().should('include', 'Kitchen Sink')'Page title is 'Cypress Kitchen Sink'Verify page title contains 'Kitchen Sink'PASS
5Test completes and Cypress CLI reports test resultsTest suite finished with all tests passing-PASS
Failure Scenario
Failing Condition: The <h1> element is not found or not visible on the page
Execution Trace Quiz - 3 Questions
Test your understanding
What command starts the Cypress test in this example?
Anpm start
Bnpx cypress run
Ccypress open
Dnode test.js
Key Result
Using Cypress CLI to run tests allows automated execution without opening the GUI, making it ideal for continuous integration and fast feedback.