0
0
Cypresstesting~10 mins

GitHub Actions integration in Cypress - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test runs a simple Cypress test using GitHub Actions. It opens a webpage, clicks a button, and checks if a message appears. The test verifies that the GitHub Actions workflow correctly runs Cypress tests and reports results.

Test Code - Cypress
Cypress
/// <reference types="cypress" />
describe('GitHub Actions Cypress Test', () => {
  it('Visits example page and checks button click', () => {
    cy.visit('https://example.cypress.io')
    cy.get('a[href="/commands/actions"]').click()
    cy.url().should('include', '/commands/actions')
    cy.get('.action-btn').first().click()
    cy.get('.action-btn').first().should('have.class', 'btn-primary')
  })
})
Execution Trace - 8 Steps
StepActionSystem StateAssertionResult
1GitHub Actions workflow starts and sets up Node.js environmentGitHub runner is ready with Node.js and Cypress installed-PASS
2GitHub Actions runs 'npm install' to install dependenciesAll Cypress dependencies installed successfully-PASS
3GitHub Actions runs 'npx cypress run' to execute Cypress testsCypress opens a headless browser and starts tests-PASS
4Cypress visits 'https://example.cypress.io'Example Cypress page is loaded in browserPage loads without errorsPASS
5Cypress finds link with href '/commands/actions' and clicks itBrowser navigates to '/commands/actions' pageURL includes '/commands/actions'PASS
6Cypress finds first button with class '.action-btn' and clicks itButton is clicked, triggering UI changes-PASS
7Cypress checks that the clicked button has class 'btn-primary'Button has expected styling classButton has class 'btn-primary'PASS
8Cypress test finishes and reports successTest results are output to GitHub Actions logs-PASS
Failure Scenario
Failing Condition: If the button with class '.action-btn' is not found or does not have class 'btn-primary' after click
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after clicking the button?
AThe button has the class 'btn-primary'
BThe button disappears from the page
CThe URL changes to the homepage
DAn alert popup appears
Key Result
Use clear, stable selectors and verify UI changes after user actions to ensure tests catch real issues. Integrate tests in CI like GitHub Actions to automate quality checks.