Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a responsive test, set the application viewport with cy.viewport(width, height), or define viewportWidth and viewportHeight in Cypress configuration. Those settings control the page under test. If you need to change the headless browser window used for screenshots or video, configure the separate before:browser:launch event.

The two meanings of browser size in Cypress

Cypress uses “viewport” and “screen” for different layers. Choosing the wrong layer is the most common reason a resize appears not to work.

Need Use What changes
Resize the page during a test cy.viewport(width, height) or a named preset The application viewport for the current test
Choose a default page size for runs viewportWidth and viewportHeight in Cypress configuration The default application viewport, reset between tests
Use a different size for one test or suite A test or suite configuration object A scoped application viewport
Override dimensions from CI or a terminal --config or the documented CYPRESS_VIEWPORT_WIDTH and CYPRESS_VIEWPORT_HEIGHT variables Run-level application configuration
Change the headless display used for screenshots or video before:browser:launch The browser screen/rendering window, separately from the Cypress application viewport

The Cypress application viewport defaults to 1000 by 660 pixels. A preview in the Cypress runner can be visually scaled to fit its pane; that scaling does not alter the dimensions reported to the application.

Resize the application in one test

Call cy.viewport() before the assertions that depend on layout. The numeric form takes width first and height second.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
describe('responsive navigation', () => {
  it('shows the desktop navigation', () => {
    cy.viewport(1280, 720)
    cy.visit('/dashboard')
    cy.get('[data-cy=desktop-nav]').should('be.visible')
    cy.get('[data-cy=menu-button]').should('not.be.visible')
  })

  it('shows the mobile menu', () => {
    cy.viewport(390, 844)
    cy.visit('/dashboard')
    cy.get('[data-cy=menu-button]').should('be.visible')
    cy.get('[data-cy=desktop-nav]').should('not.be.visible')
  })
})

Place the command before cy.visit() when you want the initial page load to occur at that size. Cypress also resizes an already loaded page when the command runs, but components that calculate dimensions only during startup may need to be reloaded or explicitly exercised after the resize.

Use Cypress device presets and orientation

The preset form supplies a documented width and height for a named device profile:

it('renders the phone layout', () => {
  cy.viewport('iphone-6')
  cy.visit('/pricing')
  cy.get('[data-cy=mobile-header]').should('be.visible')
})

Add landscape as the second argument to swap the preset dimensions:

it('renders the phone landscape layout', () => {
  cy.viewport('iphone-6', 'landscape')
  cy.visit('/pricing')
})

Presets are convenient for breakpoint tests, but they are not complete physical-device emulation. In particular, cy.viewport() does not simulate a device pixel ratio. Test high-density rendering separately if your application has DPR-specific behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set a default size in cypress.config.js or cypress.config.ts

Use configuration when most tests should start at the same dimensions. The default is restored between tests, so one test’s resize does not silently become the next test’s starting point.

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  viewportWidth: 1280,
  viewportHeight: 720,
  e2e: {
    baseUrl: 'http://localhost:3000'
  }
})

The equivalent TypeScript configuration is:

import { defineConfig } from 'cypress'

export default defineConfig({
  viewportWidth: 1280,
  viewportHeight: 720,
  e2e: {
    baseUrl: 'http://localhost:3000'
  }
})

Use configuration for a stable project-wide baseline, then call cy.viewport() for a test that intentionally covers another breakpoint.

Apply a size only to a suite or test

A configuration object keeps special dimensions local instead of changing the project default:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
describe('tablet checkout', {
  viewportWidth: 1024,
  viewportHeight: 768
}, () => {
  it('keeps the order summary visible', () => {
    cy.visit('/checkout')
    cy.get('[data-cy=order-summary]').should('be.visible')
  })
})

it('uses a narrow phone width', {
  viewportWidth: 375,
  viewportHeight: 667
}, () => {
  cy.visit('/checkout')
  cy.get('[data-cy=menu-button]').should('be.visible')
})

The scoped values apply to that suite or test and then return to the previous defaults. This is useful when a spec contains desktop, tablet and phone cases without repeatedly editing global configuration.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Override the viewport from the command line or environment

For a one-off local run or a CI matrix, pass both dimensions through --config:

npx cypress run --config viewportWidth=1280,viewportHeight=720

Cypress also documents environment-variable overrides:

CYPRESS_VIEWPORT_WIDTH=1280 CYPRESS_VIEWPORT_HEIGHT=720 npx cypress run

These are run-level values. A later cy.viewport() call or a more specific test configuration can still select a different size where the test requires it.

Change the headless browser screen for screenshots and video

If the page has the expected responsive layout but the captured screenshot or video has the wrong outer dimensions, you are changing the wrong setting. The headless browser screen is configured in the before:browser:launch event, not with cy.viewport().

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For Chromium-based browsers, add a window-size argument in your Cypress configuration:

const { defineConfig } = require('cypress')

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      on('before:browser:launch', (browser, launchOptions) => {
        if (browser.family === 'chromium' && browser.isHeadless) {
          launchOptions.args.push('--window-size=1440,900')
        }

        if (browser.name === 'electron') {
          launchOptions.preferences.width = 1440
          launchOptions.preferences.height = 900
        }

        return launchOptions
      })
    }
  }
})

Cypress documents a 1280 by 720 headless screen and device pixel ratio 1 as browser-launch defaults. Those values describe the browser display used for rendering; they are not the 1000 by 660 application-viewport defaults. Keep both settings explicit when reproducible visual output matters.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Browser launch APIs vary by browser family. Inspect the supplied launch object before changing it, preserve existing arguments and preferences, and return the object from the callback. Do not expect a window-size argument to change media-query behavior if the application viewport remains configured to another size.

Build reliable responsive tests

Test breakpoints, not every possible pixel

Select widths immediately below, at and above each breakpoint that changes behavior. For example, if navigation switches at 768 pixels, cover a narrow mobile width, 767, 768 and a representative desktop width. This catches off-by-one CSS conditions without creating an unmaintainable test for every width.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Assert behavior instead of implementation

Check whether the menu button, navigation, grid or dialog is visible and usable. Avoid asserting internal CSS values unless the value itself is the requirement. A behavior assertion survives harmless changes to class names and spacing.

Set the size before visiting

Putting cy.viewport() before cy.visit() makes the first document load occur under the intended media-query conditions and avoids testing a desktop-first initialization by accident.

Keep viewport changes isolated

Use one viewport per test when possible. Multiple resizes in one test can be valid for a resize interaction, but they make failures harder to diagnose and can leave application state created at the wrong dimensions.

Remember that preview size is not test size

Open Mode may shrink the preview to fit the runner pane. Read the dimensions from the Cypress command log or application behavior, not from the apparent size of the preview on your monitor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot incorrect dimensions

The layout stays desktop after cy.viewport()

  • Confirm the command runs before the layout assertion and, preferably, before cy.visit().
  • Check that the assertion is made against the application under test, not a separate browser chrome element.
  • Look for CSS breakpoints that differ from the width you selected; a 768-pixel breakpoint will not activate at 800 pixels.
  • If the application calculates dimensions only at startup, reload after resizing or trigger the same resize handler your production code uses.

The screenshot or video has the wrong outer size

  • Set the headless browser screen in before:browser:launch.
  • Keep the launch setting separate from viewportWidth and viewportHeight; both may need values.
  • Run in the same browser family and headless mode as CI, because launch options are browser-specific.

Cypress.config() throws when changing viewport dimensions

In Cypress 16.0.0 and later, changing viewportWidth or viewportHeight through Cypress.config() while a test is executing throws an error. Use cy.viewport() for a runtime resize, or put the values in a test or suite configuration object.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

A mobile preset does not look like a real phone

A preset supplies dimensions and orientation only. It does not reproduce a physical device’s device pixel ratio or every browser and operating-system behavior. Use a real-device or dedicated device-emulation strategy when those characteristics are part of the requirement.

The CI result differs from local runs

  • Pin the same viewport values in configuration or the command line rather than relying on a runner window.
  • Set the headless screen explicitly when comparing screenshots or videos.
  • Use identical browser family, headless mode and application build.
  • Check whether a CI environment variable is overriding the configuration.

Performance, repeatability and cost considerations

Changing a viewport is inexpensive compared with starting a new browser, but visiting a page after every size still incurs the page’s normal network, JavaScript and fixture setup time. Keep shared setup in hooks, and avoid capturing full-page artifacts for every breakpoint unless visual review requires them.

For visual regression, standardize application viewport, headless screen, browser family, device pixel ratio and fonts. A mismatch in any one of these can produce image differences that are unrelated to responsive CSS. Cypress’s runner scaling should never be used as a visual-baseline setting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For parallel CI, represent each target width as a deliberate test case or matrix value. Record the selected dimensions in the test name or artifact metadata so a failure identifies its responsive scenario immediately.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a clean screenshot rather than an interactive Cypress assertion, ScreenshotNeo returns an image or PDF from one request. Its API accepts PNG, JPEG or WebP output, and it can capture full pages, selected elements, custom viewports, dark mode, retina scale and PDFs without you maintaining a browser-launch configuration.

Use the API documentation at https://screenshotneo.com/docs/ for the complete option list. A basic cURL request is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

The same request in Python:

import requests

r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

And in Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is included on every plan. Create a free ScreenshotNeo account to get started.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

FAQ

Can I use a named preset and then fine-tune its width?

Use the preset for its documented dimensions, then issue a numeric cy.viewport() call when the test reaches the custom case. Keep the custom value visible in the test so readers can see which breakpoint is being exercised.

Should screenshot baselines use the application viewport or the headless screen?

They should use both as fixed inputs: the application viewport determines responsive layout, while the headless screen determines the rendered browser surface and artifact dimensions. Record both in the baseline setup.

Does changing viewport dimensions emulate device pixel ratio?

No. Cypress viewport presets and numeric dimensions set CSS viewport size and orientation; they do not simulate device pixel ratio. Add a separate DPR-aware test strategy when your rendering depends on high-density displays.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I use a named preset and then fine-tune its width?

Use the preset for its documented dimensions, then issue a numeric cy.viewport() call for the custom case and keep that value explicit in the test.

Should screenshot baselines use the application viewport or the headless screen?

Fix both: the application viewport controls responsive layout, and the headless screen controls the rendered browser surface and artifact dimensions.

Does changing viewport dimensions emulate device pixel ratio?

No. Cypress dimensions set CSS viewport size and orientation only; device-pixel-ratio behavior needs a separate test strategy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.