Are you tired of waiting for your Playwright test suite to finish? Do you want to run tests across multiple operating systems and browsers without the hassle of managing complex infrastructure? With Microsoft Playwright Testing, you can speed up your test runs and improve test coverage by seamlessly executing tests across various OS-browser combinations.
In this post, we’ll dive into the cloud-hosted browsers feature offered by the service, explore how it works, and learn how to integrate it with your existing Playwright test suite.
Microsoft Playwright Testing service
Microsoft Playwright Testing is a managed service that leverages the cloud to allow much higher test parallelization across different OS-browser combinations. This means faster test runs with broader coverage, enabling quicker feature delivery without compromising quality.
As your web application grows, your test suite expands, leading to longer execution times that can bottleneck your CI pipeline and delay feature delivery. Modern web apps must work flawlessly across various browsers and operating systems, adding to test duration. Microsoft Playwright Testing eliminates these limitations by running your tests on cloud-hosted browsers, allowing you to:
- Expedite test runs: Run more tests in parallel without worrying about local resource constraints.
- Improve test coverage: Easily test across different browsers and operating systems, with infrastructure management handled by the service.
- Test with confidence: Rely on a managed infrastructure for consistent results, reducing test flakiness with no additional overhead.
How does the service work?
The Playwright Testing service utilizes Playwright OSS’s native ability to run multiple tests in parallel. When you trigger a test run, Playwright spins up multiple worker processes, each responsible for launching its own browser instance.
When running tests on your dev machine, the number of browsers you can launch is restricted by your system's resources. This limitation becomes even more pronounced in CI pipelines, where large test suites need to be executed, often causing delays as teams wait for results to move forward.
With Microsoft Playwright Testing, however, the browsers are hosted and managed in the cloud. This eliminates local resource constraints, enabling you to run many more tests in parallel. Additionally, you can choose the operating system where the browsers are hosted, improving test coverage without increasing complexity.
How to Integrate Your Test Suite with Microsoft Playwright Testing
To get started with Microsoft Playwright Testing, follow these steps:
Prerequisites
- A functioning Playwright test suite in JS/TS using the Playwright Test Runner. If you don't have one, create it by using the Playwright getting started documentation or use our Microsoft Playwright Testing sample project.
- An Azure account with an active subscription. If you don't have an Azure subscription, create a free account before you begin.
- Azure CLI installed download it here.
Steps to integrate
-
Create a Playwright Testing workspace:
- Sign in to service portal using your Azure credentials.
- Select your subscription, click New Workspace, and provide the following information:
Field Description Workspace name Enter a unique name to identify your workspace. The name can only consist of alphanumerical characters and must be between 3 and 64 characters long. Azure subscription Select the Azure subscription that you want to use for this Microsoft Playwright Testing workspace. Region Select a geographic location to host your workspace. This is the location where the test run data is stored for the workspace. - Click Create workspace to create it within your subscription. Once the workspace is created, you will be taken to a page with instructions to get started.
-
Install the service package in your Playwright project:
In your IDE, navigate to Playwright project and run the following command. This will create a
playwright.service.config.ts
file alongside your Playwright config file, enabling tests to run on the service.
npm init @azure/microsoft-playwright-testing
-
Set up Authentication:
Microsoft Entra ID is the default and recommended authentication for the service. Run this command to sign in:
Note: Before running this command, make sure you have Azure CLI installed.
az login
-
Configure region endpoint:
Copy the region endpoint from service portal and set it as 'PLAYWRIGHT_SERVICE_URL' environment variable in your test setup.
-
Run the tests on the service:
Run the following command. This will create 20 workers, each executing a test on the browsers hosted on the service.
npx playwright test --config=playwright.service.config.ts --workers=20
Next steps
-
Run tests across different operating systems:
- Modify the
playwright.service.config.ts
file to change the operating system. Learn more here.
- Modify the
-
Test locally hosted applications:
- To test locally hosted or private applications, set the
exposeNetwork
field inplaywright.service.config.ts
. Learn more here.
- To test locally hosted or private applications, set the
-
Integrate MPT with CI pipelines to expedite test execution:
- Integrating the service in CI pipelines is easy. Here’s the documentation.
Conclusion
Microsoft Playwright Testing streamlines your testing workflows, allowing you to run tests across multiple operating systems and browsers without the complexity of managing infrastructure. By integrating cloud-hosted browsers into your existing Playwright test suite, you can significantly reduce test execution times, improve test coverage, and enhance overall efficiency—leading to faster feature delivery and smoother releases.
Learn more
- Get started with Microsoft Playwright Testing.
- Explore Playwright Testing features.
- Check out the pricing.
- Join the mpt-service channel on our Discord community.
- Playwright on YouTube.
Top comments (1)
Isnt azure too expensive? Can you give us an example how it compares to github actions?