October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Run Playwright Screenshot Tests in Azure DevOps

A practical Azure Pipelines guide to Playwright screenshot assertions, stable visual baselines, test reports, CI parallelism, and failure diagnosis.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run Playwright screenshot tests in Azure DevOps by installing the project’s locked Node dependencies and matching Playwright browsers, running the tests in an Azure Pipelines job, and publishing test results and the HTML report even when a test fails. Use expect(page).toHaveScreenshot() for visual comparisons, commit reviewed baselines, and keep the CI rendering environment consistent with the one used to create them.

Set up the Azure Pipelines job

Azure DevOps runs YAML CI jobs through Azure Pipelines. This Linux example installs the browser binaries and system dependencies, runs the Playwright suite, and publishes both JUnit results and the HTML report after success or failure.

As an Amazon Associate I earn from qualifying purchases.

trigger:
- main

pool:
  vmImage: ubuntu-latest

steps:
- task: UseNode@1
  inputs:
    version: '22'
  displayName: 'Install Node.js'

- script: npm ci
  displayName: 'Install locked dependencies'

- script: npx playwright install --with-deps
  displayName: 'Install Playwright browsers and Linux dependencies'

- script: npx playwright test
  displayName: 'Run Playwright tests'
  env:
    CI: 'true'

- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testResultsFormat: JUnit
    testResultsFiles: 'test-results/e2e-junit-results.xml'
    failTaskOnFailedTests: true
  displayName: 'Publish JUnit test results'

- task: PublishPipelineArtifact@1
  condition: succeededOrFailed()
  inputs:
    targetPath: 'playwright-report'
    artifact: 'playwright-report'
  displayName: 'Publish Playwright HTML report'

The Node 22 value follows Playwright’s sample CI configuration; it is not a universal requirement. Use a Node version supported by your project, and commit a package-lock.json consistent with the installed @playwright/test version. Playwright’s CI guidance distinguishes Linux from Windows and macOS: Linux needs browser system dependencies installed through the CLI or a suitable container, while its Windows and macOS examples need no additional browser configuration beyond installing Playwright and running tests. Playwright CI documentation.

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

Configure reporters in Playwright

JUnit output makes test cases available in Azure DevOps’ test results view. Configure it in playwright.config.ts:

#1 Best Overall
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
import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: [
    ['list'],
    ['junit', { outputFile: 'test-results/e2e-junit-results.xml' }],
    ['html', { outputFolder: 'playwright-report', open: 'never' }],
  ],
});

Ensure the directories and reporter output paths match the pipeline task inputs. The succeededOrFailed() condition allows the publishing tasks to run after a failed test command; it does not make the test itself pass. failTaskOnFailedTests: true also keeps a failing test result visible as a pipeline failure. Azure documents the publication tasks at PublishTestResults@2 and PublishPipelineArtifact@1.

Add screenshot assertions and baseline files

Use Playwright Test’s screenshot assertion where the rendered state is meaningful to the test:

import { test, expect } from '@playwright/test';

test('landing page visual appearance', async ({ page }) => {
  await page.goto('/');
  await expect(page).toHaveScreenshot('landing.png');
});

On an initial run, Playwright creates a reference screenshot. Inspect that image, confirm it represents the intended UI, then commit the generated snapshot directory with the test. Later runs capture the page again and compare it against that committed baseline. Do not accept an unexplained diff simply because the test is running in CI; first determine whether the UI changed intentionally or the environment changed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

Control rendering differences

Visual output can vary with operating system, browser version, browser settings, hardware, power source, and headless mode. Generate and review baselines in the same environment used for CI wherever possible. Browser projects can also be part of the test configuration; keep the CI browser versions aligned with the Playwright package and its installed browsers. See Playwright’s guidance on visual comparisons and snapshots.

For genuinely volatile regions, Playwright supports applying a stylesheet during screenshot capture to hide or neutralize those areas. Keep any masking or suppression narrowly scoped: hiding a changing timestamp may be reasonable, while hiding a whole component can conceal a real regression. Adjust pixel tolerances only when the remaining variation is understood and the test still detects changes that matter.

Choose an agent and parallelism strategy

Hosted Linux agent

The ubuntu-latest job above uses an Azure-hosted Linux agent and runs npx playwright install --with-deps. It is a direct option when you want the pipeline to install browsers and their Linux dependencies as part of the run.

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.

Version-matched Playwright container

A container can make the browser and operating-system environment more controlled. Playwright’s CI page includes the versioned example image mcr.microsoft.com/playwright:v1.63.0-noble; treat that as an example, not a standing instruction to use that version. Select an image matching the Playwright version in your repository and update the image along with that dependency. A mismatch can produce missing-browser or compatibility problems. Playwright CI examples.

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

Start with one worker; shard when needed

For predictable CI behavior, Playwright recommends limiting workers to one in CI and allowing the default locally:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  workers: process.env.CI ? 1 : undefined,
});

If a single-worker run takes too long, shard the suite across separate Azure jobs rather than immediately increasing concurrency on one agent. For example, a two-job strategy can run:

Rank #4
Sale
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
npx playwright test --shard=1/2
npx playwright test --shard=2/2

Use Azure matrix jobs or equivalent YAML job definitions to assign one shard per job. Keep each shard’s browser setup and reporting paths consistent, and avoid having multiple jobs overwrite a shared artifact name. Sharding can reduce elapsed time by distributing tests, but adds job and artifact coordination. Playwright’s CI recommendations are at its CI guide.

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

Diagnose failed or intermittent screenshot tests

Capture traces on retry

Configure traces to be collected on the first retry so intermittent CI failures include a diagnostic record without tracing every successful test:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { defineConfig } from '@playwright/test';

export default defineConfig({
  retries: process.env.CI ? 1 : 0,
  use: {
    trace: 'on-first-retry',
  },
});

Open a trace using the Playwright report or trace viewer. Trace data can show the test timeline, DOM snapshots, and network requests. Recording traces for every test has a performance cost, which is why retry-based capture is a practical default for intermittent CI failures. Playwright Trace Viewer.

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.

Common failure patterns

  • Browser executable or shared-library missing: On Linux, ensure the browser-install step runs and includes --with-deps, or use a compatible Playwright container. Check that the container’s Playwright version matches the project dependency.
  • Screenshot differs only in CI: Compare OS, browser version, headless mode, fonts, settings, and hardware between baseline creation and CI. Recreate a baseline only after verifying the intended appearance in the CI-equivalent environment.
  • JUnit results do not appear: Confirm the JUnit reporter is configured, its output file is exactly test-results/e2e-junit-results.xml, and the Azure task pattern points to that file.
  • HTML report artifact is missing: Confirm the HTML reporter writes to playwright-report, and that the publication step runs with succeededOrFailed(). A publication task cannot upload a directory the reporter never generated.
  • Pipeline is slower or less stable after adding workers: Return to one worker per CI agent, then distribute load through shards if shorter wall-clock time is necessary.

Remote browsers need special snapshot care

Microsoft’s Playwright Workspaces guidance warns that the test runner uses the host operating system in expected screenshot paths. If local tests connect to remote browsers running another OS, expected snapshots can differ even when the application is unchanged. For Workspaces runs, Microsoft recommends running comparisons in the service rather than comparing service screenshots with local ones; configure ignoreSnapshots for the relevant run if needed. This advice is specific to Workspaces and should not be applied blindly to ordinary Azure-hosted local-browser runs. Microsoft Playwright Workspaces visual comparisons.

Or skip the browser setup

If your task is to capture a page image rather than assert a committed Playwright baseline, ScreenshotNeo offers a one-request screenshot API and an MCP server for AI agents. Here is the cURL call:

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 removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.

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

Frequently Asked Questions

Does Azure DevOps require a paid product to run Playwright screenshot tests?

The workflow described here uses Playwright tests, YAML pipeline steps, and Azure Pipelines test-result and artifact publication tasks; it does not require a separate screenshot-testing service.

Can I use screenshots captured from Playwright Workspaces as local baselines?

Microsoft warns that differing host and remote operating systems can make visual comparisons fail. For Workspaces, follow Microsoft’s service-specific recommendation to run comparisons in the service.

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 *

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.

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.