0
0
Cypresstesting~10 mins

cypress.config.js settings - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test verifies that Cypress correctly loads and applies settings from the cypress.config.js file, such as baseUrl and viewport size.

Test Code - Cypress
Cypress
describe('Cypress Config Settings Test', () => {
  it('should use baseUrl and viewport from cypress.config.js', () => {
    cy.visit('/')
    cy.url().should('eq', `${Cypress.config('baseUrl')}/`)
    cy.window().then((win) => {
      expect(win.innerWidth).to.equal(Cypress.config('viewportWidth'))
      expect(win.innerHeight).to.equal(Cypress.config('viewportHeight'))
    })
  })
})
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsCypress test runner is initialized with cypress.config.js settings loaded-PASS
2Cypress opens browser and applies viewport size from configBrowser window is set to viewportWidth and viewportHeight from cypress.config.js-PASS
3Test navigates to baseUrl '/' using cy.visit('/')Browser navigates to the URL defined by baseUrl in cypress.config.jsVerify current URL equals baseUrl + '/'PASS
4Test retrieves viewport size using cy.window() and compares with configViewport size is available from Cypress APIViewport width and height match viewportWidth and viewportHeight from configPASS
5Test ends successfullyAll assertions passed, test completes-PASS
Failure Scenario
Failing Condition: If cypress.config.js is missing or baseUrl is incorrect, cy.visit('/') will fail to load the page
Execution Trace Quiz - 3 Questions
Test your understanding
What does cy.visit('/') do in this test?
ANavigates to the root of the local file system
BNavigates to the baseUrl defined in cypress.config.js
COpens a new browser tab without loading a page
DResets the viewport size to default
Key Result
Always verify that your cypress.config.js settings like baseUrl and viewport sizes are correctly set and reachable before running tests to avoid navigation and layout failures.