Device & Viewport Emulation in Playwright
From the Playwright cheat sheet ยท Emulation & Devices ยท verified Jul 2026
Device & Viewport Emulation
Test on mobile devices, custom viewports, and different screen configurations
typescript
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [
{ name: 'Desktop', use: { viewport: { width: 1280, height: 720 } } },
{ name: 'Mobile', use: { ...devices['iPhone 13'] } },
{ name: 'Tablet', use: { ...devices['iPad Pro 11'] } },
],
});๐ก Playwright ships with 100+ device profiles โ use devices["Device Name"] to emulate any of them
โก Device profiles include viewport, userAgent, deviceScaleFactor, isMobile, and hasTouch
๐ Use page.setViewportSize() mid-test to verify responsive breakpoints dynamically
๐ข Each project runs your entire test suite โ great for cross-device coverage in CI
emulationdevicesviewportmobile