0
0
Cypresstesting~10 mins

it blocks for test cases in Cypress - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test uses an it block in Cypress to check if the homepage loads and contains the expected welcome text.

Test Code - Cypress
Cypress
describe('Homepage Tests', () => {
  it('should load the homepage and display welcome text', () => {
    cy.visit('https://example.cypress.io')
    cy.get('h1').should('contain.text', 'Kitchen Sink')
  })
})
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts with 'it' block named 'should load the homepage and display welcome text'Test runner is ready to execute the test-PASS
2Browser opens and navigates to 'https://example.cypress.io'Browser shows the homepage of the Cypress example site-PASS
3Finds the <h1> element on the pageThe <h1> element with text 'Kitchen Sink' is visibleCheck that <h1> contains text 'Kitchen Sink'PASS
4Assertion checks that the <h1> text includes 'Kitchen Sink'Text matches expected contentcy.get('h1').should('contain.text', 'Kitchen Sink')PASS
5Test completes successfullyTest runner marks test as passed-PASS
Failure Scenario
Failing Condition: The <h1> element does not contain the text 'Kitchen Sink' or is not found
Execution Trace Quiz - 3 Questions
Test your understanding
What does the 'it' block represent in this Cypress test?
AA command to open the browser
BA group of multiple test cases
CA single test case that runs the steps inside it
DAn assertion to check text on the page
Key Result
Use 'it' blocks in Cypress to define clear, single test cases that describe what the test checks. This helps keep tests organized and readable.