{
  "slug": "set-viewport-dimensions-through-cy-viewport-or-test-configuration-c623c3eb0266",
  "title": "Set viewport dimensions through cy.viewport() or test configuration",
  "tools": [
    "cypress"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-09-01T00:00:00.000Z",
  "announced_at": "2026-09-01T00:00:00.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When a test needs different viewport dimensions, call `cy.viewport(width, height)` during execution or set `viewportWidth` and `viewportHeight` in its `describe`, `context`, or `it` test configuration. Cypress 16 no longer allows changing these dimensions with `Cypress.config()` during test execution.",
    "examples": [
      "cy.viewport(550, 750)",
      "describe('page display on medium size screen', { viewportHeight: 1000, viewportWidth: 400 }, () => { it('does not display sidebar', () => { cy.get('#sidebar').should('not.be.visible') }) })"
    ],
    "gotchas": [
      "Version: 16.0.0",
      "width (required): Viewport width in pixels; must be a non-negative, finite number.",
      "height (required): Viewport height in pixels; must be a non-negative, finite number.",
      "viewportWidth (required): Test configuration key for viewport width in pixels.",
      "viewportHeight (required): Test configuration key for viewport height in pixels.",
      "describe(name, config, fn) (required): Pass a configuration object as the second argument to set values for a suite; values reset afterward.",
      "Setting dimensions with `Cypress.config()` during test execution affected the next test rather than the current one and was not reflected in Test Replay."
    ]
  },
  "why_it_matters": "Change viewport dimensions during a test or define them for a test suite.",
  "before": "Before Cypress 16, changing `viewportWidth` or `viewportHeight` with `Cypress.config()` during test execution affected the next test and was not reflected in Test Replay.",
  "sources": [
    "https://docs.cypress.io/app/references/changelog#16-0-0",
    "https://docs.cypress.io/api/commands/viewport",
    "https://docs.cypress.io/app/references/configuration",
    "https://docs.cypress.io/app/references/migration-guide/migrating-to-cypress-16-0.md"
  ],
  "rank": 0.9203,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2b-20261017",
    "verdict_id": "wave2b-20261017:wave2b-20261017-6d36062861832e83-11:gate",
    "evidence_hash": "bfb253efa25c476508053eff19d72e8789fa70be04071a80b9a86cf6562828b1"
  },
  "review": {
    "draft_hash": "12a9ce59a44332f09e5171278750e3de499c124adbf385c5ded17a1eb2e6c082",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2b-20261017:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.92 >= 0.9; 2 needed) and Jev gave 0.73 (>= 0.6 needed)."
  }
}
