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

Set the browser viewport with cy.viewport(), wait for the mobile layout to reach the state you want, then call cy.screenshot(). Use { capture: 'viewport' } for the visible area or { capture: 'fullPage' } for the page from top to bottom.

Capture a mobile-sized website in Cypress

This test sets a 375 × 667-pixel viewport, opens the application, waits for its heading to appear, and saves a screenshot of the visible application area:

describe('mobile layout', () => {
  it('captures the mobile home page', () => {
    cy.viewport(375, 667)
    cy.visit('/')
    cy.get('h1').should('be.visible')
    cy.screenshot('mobile-home', { capture: 'viewport' })
  })
})

Replace / and the heading assertion with the route and condition that identify the specific page state your test needs. Cypress’s screenshot command is asynchronous; the page can change while the image is being captured. Establish the required state before calling it rather than relying on the screenshot to freeze the page at command enqueue time. Cypress documents the screenshot command and its behavior.

Choose dimensions or a device preset

cy.viewport(width, height) sets the application viewport in pixels. Use explicit dimensions to test a responsive breakpoint, or a named preset as a convenient size:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
cy.viewport(375, 667)
// or
cy.viewport('iphone-6')
// Landscape reverses the preset's width and height:
cy.viewport('iphone-6', 'landscape')
Preset Portrait viewport Landscape example
iphone-5 320 × 568 px 568 × 320 px
iphone-6 375 × 667 px 667 × 375 px
iphone-x 375 × 812 px 812 × 375 px
samsung-s10 360 × 760 px 760 × 360 px

These are viewport presets, not full simulations of the named physical devices. Cypress states that devicePixelRatio is not simulated. The Test Runner may scale its preview to fit the pane, but that visual scaling does not change the configured dimensions. Cypress’s default viewport is 1000 × 660 pixels; see the viewport API for preset details.

Select what the screenshot includes

  • Visible application area: cy.screenshot('mobile-visible-area', { capture: 'viewport' }) captures the current viewport.
  • Whole page: cy.screenshot('mobile-full-page', { capture: 'fullPage' }) captures from the top to the bottom. fullPage is the documented default for manual screenshots.
  • Runner: { capture: 'runner' } captures the browser viewport with Cypress Command Log chrome, subject to Cypress’s documented Test Replay and failure-screenshot behavior.
  • Cropped viewport: Supply a pixel-based clip rectangle, such as cy.screenshot('mobile-crop', { capture: 'viewport', clip: { x: 0, y: 0, width: 375, height: 300 } }).
  • One element: Select it and call .screenshot(), for example cy.get('[data-testid="checkout"]').screenshot('checkout').

The Cypress screenshot API also documents callbacks that expose details such as the saved path and image dimensions.

Set a project default and find the output

To make tests start at mobile dimensions by default, set viewportWidth and viewportHeight in Cypress configuration. Cypress’s defaults are 1000 and 660, respectively. The default screenshot folder is cypress/screenshots. You can still change viewport dimensions within a test using cy.viewport(). Configuration options are listed in Cypress configuration documentation.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

Cypress resets the viewport to the configured default between tests. For a suite or test that needs a different default, use test configuration; do not try to change viewportWidth or viewportHeight through Cypress.config() during test execution. Starting with Cypress 16.0.0, doing so throws; use cy.viewport() or test configuration instead. See the Cypress.config() API.

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

Manual screenshots can be saved in either cypress open or cypress run. Cypress captures a failure screenshot by default during cypress run, but not during cypress open; the screenshotOnRunFailure setting controls that behavior. See Cypress’s screenshots and videos guide.

Make captures consistent for visual review

cy.screenshot() saves an image; it does not compare that image with a baseline. Cypress’s visual testing guide recommends generating and comparing screenshots in the same environment with a fixed viewport. Operating systems, browser versions, display scaling, and installed fonts can change rendering.

Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
  • Keep the viewport dimensions and execution environment the same for baseline and candidate captures.
  • Assert that the intended responsive state is present before capturing.
  • Avoid taking the screenshot mid-transition. Cypress normally disables JavaScript timers and CSS animations during capture; its screenshot defaults can be customized.

Troubleshoot common mobile screenshot problems

The result does not look like the Test Runner preview

The Runner may scale its preview to fit its pane. That display scaling does not alter the test’s viewport dimensions. Check the dimensions passed to cy.viewport() and inspect the saved image rather than judging size from the preview.

The layout differs from a real phone

A viewport preset sets browser viewport dimensions; it is not complete physical-device emulation. In particular, Cypress does not simulate devicePixelRatio. Do not interpret a passing viewport test as proof that every hardware or browser characteristic matches a named phone.

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.

The screenshot shows the wrong page state

Wait for an application-specific condition before capture, such as a visible heading or a completed request reflected in the UI. Screenshot capture is asynchronous, so the page can change during capture. Avoid relying only on a fixed delay when a test can assert the state directly.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone

The image is only the visible screen, not the whole page

Set capture: 'fullPage' explicitly when you need the top-to-bottom page. Use capture: 'viewport' when only the currently visible area is wanted.

A runtime viewport configuration throws

On Cypress 16.0.0 and later, changing viewportWidth or viewportHeight with Cypress.config() during test execution throws. Change the live viewport with cy.viewport(), or set a suite/test default through test configuration.

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 you need a website screenshot without building a Cypress test, ScreenshotNeo returns an image or PDF from one API request. For example, this cURL call saves a WebP screenshot of a mobile-sized viewport; the ScreenshotNeo documentation covers the API options.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -d width=375 -d height=667 -o shot.webp

ScreenshotNeo accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up free for 1,000 screenshots a month, with no card required.

Frequently Asked Questions

Does cy.screenshot() compare a screenshot with a baseline?

No. It captures an image; screenshot comparison requires a separate visual-testing workflow.

Does a Cypress mobile viewport test emulate a complete phone?

No. It sets viewport dimensions, but Cypress does not simulate devicePixelRatio.

Quick Recap

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.