Run Playwright screenshot tests in Azure DevOps by installing the project’s locked dependencies and browser requirements, executing the tests in an Azure Pipelines job, and publishing the JUnit results and HTML report even when a test fails. For dependable visual comparisons, generate and review baselines in an environment that matches CI, and start with one worker before considering sharding.
Set up the Azure Pipelines job
Azure DevOps runs YAML CI workflows through Azure Pipelines. The pipeline below uses a hosted Ubuntu agent, installs the Node.js version shown in Playwright’s CI example, installs the browsers and Linux dependencies, and runs the tests. The Node version is an example, not a universal requirement: use a version supported by your repository and keep the lockfile consistent with the installed @playwright/test package. See Playwright’s CI guidance.
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: UseNode@1
inputs:
version: '22'
displayName: 'Install Node.js'
- script: npm ci
displayName: 'Install 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'
npm ci installs from the repository’s lockfile, so commit package-lock.json and keep it aligned with the Playwright version the project expects. On Linux, npx playwright install --with-deps installs the browser binaries and their system dependencies. Playwright’s CI documentation says Windows and macOS agents need no additional browser configuration beyond installing Playwright and running the tests.
Add a screenshot assertion and create its baseline
Use Playwright Test’s screenshot matcher in a test after the page has reached the state you intend to verify:
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import { test, expect } from '@playwright/test';
test('landing page matches its visual baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('landing.png');
});
On the first run, Playwright creates a reference screenshot rather than comparing against an existing one. Inspect the generated image, decide whether it represents the intended UI, and commit the snapshot directory with the test. Later runs compare their captured image to that committed baseline. Consult the screenshot comparison documentation for snapshot naming and comparison controls.
Keep the comparison environment consistent
Rendered pixels can vary with the operating system, browser version, browser settings, fonts, hardware, power source, and headless mode. Generate and verify baselines in the same environment used by CI where possible. Treat an unexplained difference as a possible UI change to investigate, not noise to dismiss automatically. If a difference is expected, adjust comparison tolerances only for a specific, justified reason.
For genuinely volatile regions, Playwright supports applying a stylesheet during screenshot capture to hide or neutralize the changing content. Keep suppression narrowly scoped: hiding a whole component can make a visual test pass while the part you need to check is broken.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Publish test results and the HTML report
Use Playwright’s JUnit reporter so Azure DevOps can publish test cases in its test-results view. Add both JUnit and HTML reporting in playwright.config.ts:
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchimport { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [
['junit', { outputFile: 'test-results/e2e-junit-results.xml' }],
['html', { outputFolder: 'playwright-report', open: 'never' }],
],
});
Then publish the XML and report directory as pipeline outputs. Set each publishing task to succeededOrFailed() so it runs after a failed test command. The test step itself can still fail the job; the condition allows the diagnostic outputs to be retained.
- task: PublishTestResults@2
displayName: 'Publish JUnit test results'
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'test-results/e2e-junit-results.xml'
failTaskOnFailedTests: true
- task: PublishPipelineArtifact@1
displayName: 'Publish Playwright HTML report'
condition: succeededOrFailed()
inputs:
targetPath: 'playwright-report'
artifact: 'playwright-report'
Place these tasks after the Playwright test command in the YAML. The report upload works only if that directory was produced by the configured reporter; confirm the configured output folder and path match. Azure Pipelines’ task references explain the test-results task and pipeline artifact task.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Choose a stable execution strategy
Start with one worker
Parallel workers can make a suite faster, but concurrent tests may compete for the same agent resources and make screenshot output less predictable. Playwright recommends a single worker in CI as a stability-first setting:
import { defineConfig } from '@playwright/test';
export default defineConfig({
workers: process.env.CI ? 1 : undefined,
});
This keeps the default worker behavior outside CI while limiting CI to one worker. Apply it in the same configuration that defines your reporters and other test settings.
Recommended Free Tools
Use shards when runtime is too long
If one worker makes the suite take too long, distribute test files across Azure Pipelines jobs with Playwright sharding rather than immediately increasing worker pressure on a single agent. Use --shard to select each portion of the suite, and --project when you want to shard a particular configured browser project. Configure matching shard indices and a common total across the jobs; each job must run a distinct shard. See Playwright’s sharding guide for the invocation pattern and merging guidance.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Use a version-matched container when needed
Playwright also documents a Linux container option, including a versioned example based on mcr.microsoft.com/playwright:v1.63.0-noble. That tag is an example, not a recommendation to pin that release for every project. Choose an image matching the Playwright dependency in the repository, and update the image when you update that dependency. A container can make the browser environment more controlled; a hosted Linux agent with install --with-deps is a simpler starting point. See the CI examples.
Diagnose intermittent CI failures with traces
Configure tracing to record on the first retry. A trace can show the test timeline, DOM snapshots, and network requests, helping distinguish an application issue from a timing or environment problem. Playwright cautions that tracing every test has a performance cost, which is why retry-based capture is a practical default.
import { defineConfig } from '@playwright/test';
export default defineConfig({
retries: process.env.CI ? 1 : 0,
use: {
trace: 'on-first-retry',
},
});
When a test retries, open the resulting trace from the Playwright HTML report or with the trace viewer. Consult Playwright’s trace viewer documentation for how to inspect it.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Account for remote-browser operating systems
Screenshot baselines depend on the environment that captures them. Microsoft’s Playwright Workspaces guidance warns that the runner uses the host operating system when forming expected screenshot paths; comparing a local baseline with a remote browser on a different OS can therefore fail. For Workspaces runs, Microsoft recommends running comparisons in the service rather than comparing service screenshots with local ones, and using ignoreSnapshots for the relevant run if necessary. This is service-specific guidance: do not apply it automatically to ordinary tests using browsers on Azure-hosted agents. See Microsoft’s Workspaces visual-comparison guidance.
Troubleshoot common pipeline problems
- Browser executable or shared-library errors on Linux: install browser system dependencies with
npx playwright install --with-deps, or use a container that matches the project’s Playwright version. - Screenshot diffs appear on every CI run: check whether the baseline and CI use the same operating system, browser version, fonts, settings, and headless mode. Recreate and inspect baselines in the target environment before changing tolerance.
- A snapshot is missing on the first run: the first assertion run creates a candidate baseline. Review and commit the generated snapshot files; subsequent runs need those reference files.
- The report artifact is missing after a failed run: verify the HTML reporter is configured to write to
playwright-report, that the publish task follows the test command, and that its condition issucceededOrFailed(). - Azure DevOps has no visible test cases: configure the JUnit reporter, ensure the XML output path matches
testResultsFiles, and publish it withPublishTestResults@2using theJUnitformat. - A local screenshot fails against a remote Workspaces browser: investigate the host-versus-remote OS difference and follow Microsoft’s Workspaces-specific comparison guidance rather than treating it as a generic Azure agent issue.
- Tests are flaky under parallel load: use one CI worker first. If the resulting duration is unacceptable, distribute work across jobs with shards and retain retry traces for intermittent failures.
Or skip the browser setup
If you need screenshots from URLs rather than Playwright visual regression tests tied to committed baselines, ScreenshotNeo provides a screenshot API and MCP server. A GET request returns a PNG, JPEG, WebP, or PDF. For example, save a WebP capture with cURL:
Quick Recap
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 capture; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.
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.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minute

