Skip to content
masterclass Buddy

Cypress · Method

cy.viewport

Changes the Cypress application viewport to custom dimensions or a named device preset. It can also switch the viewport between portrait and landscape.

Last updated

Since
0.9.0

Syntax

cy.viewport(width, height)
cy.viewport(preset, orientation)
cy.viewport(width, height, options)
cy.viewport(preset, orientation, options)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • viewportWidth
  • viewportHeight
  • Cypress.config()
  • describe
  • context
  • it

Source: cy.viewport() | Cypress API Documentation. Checked 2026-11-03.