Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

How to Test Mobile Viewports with Cypress Screenshots

Use cy.viewport() to test responsive layouts at chosen mobile dimensions, then capture the visible application with cy.screenshot({ capture: 'viewport' }). Learn how to stabilize screenshots and when to add visual comparison.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the application viewport with cy.viewport(), check the responsive behavior you expect, then save the visible screen with cy.screenshot() using capture: 'viewport'. This gives you repeatable screenshots at chosen widths and heights; it does not emulate every property of a physical phone or compare images for visual changes.

Set up repeatable mobile viewport tests

Use explicit dimensions that cover your breakpoints and the layouts your users need. The values below are examples, not a claim about the most common phone sizes; adapt them to your site. Cypress documents numeric width and height arguments for cy.viewport() and demonstrates testing multiple sizes with responsive UI assertions.

As an Amazon Associate I earn from qualifying purchases.

const mobileViewports = [
  { name: 'narrow mobile', width: 320, height: 640 },
  { name: 'typical mobile', width: 375, height: 812 },
  { name: 'wide mobile', width: 414, height: 896 },
]

describe('responsive navigation', () => {
  mobileViewports.forEach(({ name, width, height }) => {
    it(`works at ${name}`, () => {
      cy.viewport(width, height)
      cy.visit('/')

      cy.get('[data-testid="mobile-menu-button"]').should('be.visible')
      cy.get('[data-testid="desktop-navigation"]').should('not.be.visible')

      cy.screenshot(`navigation-${width}x${height}`, {
        capture: 'viewport',
      })
    })
  })
})

Replace / and the test IDs with routes and selectors in your application. Put assertions before the screenshot so the captured file corresponds to a checked state. The example uses a named screenshot per viewport, which makes artifacts easier to identify.

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

Choose dimensions that test your breakpoints

Include sizes just below and above important CSS breakpoints, as well as representative dimensions for the layouts you support. Cypress also accepts a supported device preset and portrait or landscape orientation; explicit dimensions are often clearer when the purpose is to test a particular breakpoint. Consult the Cypress viewport command documentation for supported presets and current API behavior.

#1 Best Overall
Sale
Motorola Moto g - 2026 | Unlocked | Made for US 4/128GB | 50MP Camera | Pantone Slipstream, Cellular_Phone
  • Universal unlocked. Compatible with all major U.S. carriers, including Verizon, AT&T, T-Mobile and other prepaid carriers.
  • Super-bright, super-smooth 6.7" display. See your screen clearly even outdoors in sunlight, and enjoy seamless views with a fast-refreshing 120Hz display.*
  • AI-powered camera system. Take stunning photos in any light with the 50MP camera**, look your best with a 32MP selfie cam*****, and capture extreme close-ups.
  • Superfast 5G performance. Unleash your entertainment at 5G speed*** with the MediaTek Dimensity 6300 chipset and up to 12GB of RAM with RAM Boost****.
  • Long-lasting battery + TurboPower charging. Power through day after day with a 5200mAh battery, then get hours of power in just minutes.****

cy.viewport() sets the application viewport, not a complete physical-device simulation: Cypress does not simulate devicePixelRatio. A passing test therefore shows how the page responds to the configured viewport dimensions, not how every device-specific feature behaves.

Set a default size when it belongs to the suite

Cypress documents a default viewport of 1000 by 660 pixels. To use a consistent size by default, configure viewportWidth and viewportHeight in Cypress configuration, or in a suite or test-specific configuration. Use cy.viewport() when a test needs to change size as it runs. A viewport set by that command resets to the configured default between tests. Since Cypress 16.0.0, Cypress.config() cannot be used to set viewportWidth or viewportHeight during test execution. See the Cypress configuration reference.

Rank #2
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • 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.

Choose the screenshot capture mode

For a mobile screenshot that represents the screen a user can currently see, specify capture: 'viewport'. Cypress documents three capture modes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Mode What it captures Use it for
viewport The currently visible application viewport. Reviewing a mobile layout as it appears at the chosen dimensions.
fullPage The page from top to bottom, captured by scrolling and stitching screenshots. Inspecting page-length content. Fixed or sticky elements may appear more than once in the stitched image, so this is not the same artifact as a user’s viewport.
runner The Cypress browser context, including the runner. Debugging when the surrounding Cypress context is useful.

The default capture mode is fullPage. Automatic screenshots on test failure are coerced to runner captures, so they are not equivalent to an application-only viewport screenshot. The screenshot command and options are documented in Cypress’s screenshot command reference.

Rank #3
Samsung Galaxy A16 5G 128GB Cell Phone, Unlocked Android Smartphone, Large AMOLED Display, Durable Design, Super Fast Charging, Expandable Storage, US Version, 2025, Blue Black (Renewed)
  • Charger NOT Included, 6.7" Super AMOLED FHD+, 90Hz Refresh Rate, 385 ppi, 800 nits (HBM), 1080x2340px, 5000mAh Battery
  • 128GB, 4GB RAM, microSDXC, Exynos 1330 (5nm), Octa-Core, Mali-G68 MP2 or Mali-G57 MC2 GPU
  • Rear Camera: 50MP, f/1.8 (wide) + 5MP, f/2.2 (ultrawide) + 2MP, f/2.4 (macro), LED flash, panorama, HDR; Front Camera: 13MP, f/2.0, Android 14, up to 6 major Android upgrades, One UI 6.1
  • 3G: HSDPA 850/900/1700(AWS)/1900/2100; 4G LTE: 1/2/3/4/5/7/12/13/14/20/25/26/28/29/30/38/39/40/41/48/66/71, 5G: 2/5/25/41/66/71/77/78 SA/NSA/Sub6/mmWave - Nano-SIM + eSIM
  • US Model – Global Connectivity – Compatible with Most GSM Carriers like T-Mobile, AT&T, MetroPCS, etc. Will Also work with CDMA Carriers Such as Verizon, Straight Talk.

Keep screenshots stable enough to inspect

  • Use the same explicit viewport dimensions each time you capture a given case.
  • Wait for the intended page state and assert it before taking the screenshot. If content loads asynchronously, wait for an observable condition rather than relying on an arbitrary delay alone.
  • Cypress’s screenshot API disables JavaScript timers and CSS animations by default during capture. The screenshot API also provides callbacks for synchronous adjustments before or after capture when a test needs them; check the current API documentation for the callback options.
  • For image comparisons across runs, keep the operating system, browser version, display scaling, and installed fonts consistent. Environment differences can create image diffs even when the application has not meaningfully changed, as Cypress explains in its visual testing guide.

Screenshots are written to cypress/screenshots by default; Cypress configuration can change the screenshot folder. Cypress automatically captures screenshots on failure during cypress run, but not during cypress open. See the configuration reference and screenshot command reference.

Do not confuse browser display size with the app viewport

cy.viewport() sets the application’s viewport dimensions. The before:browser:launch API can configure a headless browser’s display size, which can affect screenshots and videos separately. Changing the browser window or display size is not a substitute for setting a mobile application viewport. Cypress describes this distinction in its browser launch API documentation.

Rank #4
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue | Large AMOLED, High-Res Camera, Durable Design, Super Fast Charging, Expandable Storage, Circle to Search, 2025
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When you need visual comparison, add a comparison workflow

cy.screenshot() saves an image; it does not compare that image with a baseline. Cypress states in its visual testing guide that the built-in command captures images but does not compare them.

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

Cypress’s guide describes optional integrations for visual review, including Applitools Eyes (AI-assisted comparison), Argos (CI and pull-request review), Chromatic (cloud rendering and diffs), Happo (screenshots across browsers and screen sizes), LambdaTest SmartUI (cross-browser and resolution comparisons), and Percy (cloud rendering across browsers and responsive widths). These services differ in rendering coverage, comparison approach, pull-request workflow, and fit with a team’s Cypress and CI setup. Their current features, prices, and availability should be checked with the providers; Cypress’s guide is not a current pricing comparison.

Best Value
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.

Troubleshooting mobile screenshots

The screenshot shows a desktop layout

Confirm that the test calls cy.viewport(width, height) before checking the page, and that the test is exercising the expected route and breakpoint. Changing the headless browser’s display size with a launch event does not set the app viewport.

The screenshot is taller than the visible screen

Set capture: 'viewport' explicitly. Cypress’s default is fullPage, which scrolls and stitches the page. Expect fixed or sticky elements to repeat in a full-page image.

Images differ across machines or runs

First make the viewport and rendering environment consistent: use the same browser version, operating system, display scaling, and fonts. Then make sure the page is in the same state before capture and account for animation or time-dependent content. Differences in those conditions can produce visual diffs without a meaningful application change.

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.

No automatic failure screenshot appears in the interactive runner

Automatic failure screenshots are captured during cypress run, not cypress open. Use an explicit cy.screenshot() call when you need a screenshot during an interactive test session.

The test expects a phone-specific rendering feature

Remember that setting viewport dimensions is responsive viewport testing, not complete hardware emulation. In particular, Cypress does not simulate devicePixelRatio; validate device-specific behavior with an appropriate device-testing approach as well.

Or skip the browser setup

If you need a screenshot API rather than a Cypress test artifact, ScreenshotNeo takes a screenshot from one GET request. For example, with cURL:

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

See the ScreenshotNeo API documentation for request options. It accepts cookie or 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 or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses indicate the page verdict and billing status with X-Page-Verdict and X-Billed headers. ScreenshotNeo also provides an MCP server with 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 shots. Sign up for 1,000 free screenshots a month, with no card required.

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.