@azure/microsoft-playwright-testing package

Interfaces

MPTReporterConfig

Optional configuration for MPT Reporter.

Example

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

export default defineConfig({
 reporter: [["@azure/microsoft-playwright-testing/reporter", {
  enableGitHubSummary: true
 }]],
});

Type Aliases

AuthenticationType

Authentication types supported by Microsoft Playwright Testing.

BrowserConnectOptions

Browser connect options for the service. This includes endpoint options and connect options.

Example

import playwright, { test, expect, BrowserType } from "@playwright/test";
import { getConnectOptions, BrowserConnectOptions } from "@azure/microsoft-playwright-testing";

test("has title", async ({ browserName }) => {
 const { wsEndpoint, options } : BrowserConnectOptions = await getConnectOptions();
 const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);
 const context = await browser.newContext();
 const page = await context.newPage();

 await page.goto("https://playwright.dev/");
 await expect(page).toHaveTitle(/Playwright/);

 await page.close();
 await context.close();
 await browser.close();
});
ConnectOptions

Connect options for the service.

EndpointOptions

Endpoint options for the service.

OsType

OS Types supported by Microsoft Playwright Testing.

PlaywrightServiceAdditionalOptions

Additional options for the service.

Functions

getConnectOptions(Omit<PlaywrightServiceAdditionalOptions, "serviceAuthType">)

Get connect options required to connect to Microsoft Playwright Testing's cloud hosted browsers.

Example

import playwright, { test, expect, BrowserType } from "@playwright/test";
import { getConnectOptions } from "@azure/microsoft-playwright-testing";

test('has title', async ({ browserName }) => {
 const { wsEndpoint, options } = await getConnectOptions();
 const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);
 const context = await browser.newContext();
 const page = await context.newPage();

 await page.goto('https://playwright.dev/');
 await expect(page).toHaveTitle(/Playwright/);

 await page.close();
 await context.close();
 await browser.close();
});
getServiceConfig(PlaywrightTestConfig<{}, {}>, PlaywrightServiceAdditionalOptions)

Generate playwright configuration integrated with Microsoft Playwright Testing.

Example

import { defineConfig } from "playwright/test";
import { getServiceConfig } from "@azure/microsoft-playwright-testing";
import playwrightConfig from "./playwright.config";

export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig));

Example

import { defineConfig } from "playwright/test";
import { getServiceConfig, ServiceOS } from "@azure/microsoft-playwright-testing";
import playwrightConfig from "./playwright.config";

export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig, {
 runId: "custom run id",
 os: ServiceOS.WINDOWS
}));

Variables

ServiceAuth

Authentication types supported on Microsoft Playwright Testing

ServiceEnvironmentVariable

Environment variables used by Microsoft Playwright Testing

ServiceOS

OS types supported on Microsoft Playwright Testing cloud hosted browsers

Function Details

getConnectOptions(Omit<PlaywrightServiceAdditionalOptions, "serviceAuthType">)

Get connect options required to connect to Microsoft Playwright Testing's cloud hosted browsers.

Example

import playwright, { test, expect, BrowserType } from "@playwright/test";
import { getConnectOptions } from "@azure/microsoft-playwright-testing";

test('has title', async ({ browserName }) => {
 const { wsEndpoint, options } = await getConnectOptions();
 const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);
 const context = await browser.newContext();
 const page = await context.newPage();

 await page.goto('https://playwright.dev/');
 await expect(page).toHaveTitle(/Playwright/);

 await page.close();
 await context.close();
 await browser.close();
});
function getConnectOptions(options?: Omit<PlaywrightServiceAdditionalOptions, "serviceAuthType">): Promise<BrowserConnectOptions>

Parameters

options

Omit<PlaywrightServiceAdditionalOptions, "serviceAuthType">

additional options for the service

Returns

BrowserConnectOptions

getServiceConfig(PlaywrightTestConfig<{}, {}>, PlaywrightServiceAdditionalOptions)

Generate playwright configuration integrated with Microsoft Playwright Testing.

Example

import { defineConfig } from "playwright/test";
import { getServiceConfig } from "@azure/microsoft-playwright-testing";
import playwrightConfig from "./playwright.config";

export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig));

Example

import { defineConfig } from "playwright/test";
import { getServiceConfig, ServiceOS } from "@azure/microsoft-playwright-testing";
import playwrightConfig from "./playwright.config";

export default defineConfig(playwrightConfig, getServiceConfig(playwrightConfig, {
 runId: "custom run id",
 os: ServiceOS.WINDOWS
}));
function getServiceConfig(config: PlaywrightTestConfig<{}, {}>, options?: PlaywrightServiceAdditionalOptions): PlaywrightTestConfig<{}, {}>

Parameters

config

PlaywrightTestConfig<{}, {}>

base playwright configuration

options
PlaywrightServiceAdditionalOptions

additional options for the service

Returns

PlaywrightTestConfig<{}, {}>

PlaywrightConfig

Variable Details

ServiceAuth

Authentication types supported on Microsoft Playwright Testing

ServiceAuth: { ACCESS_TOKEN: "ACCESS_TOKEN", ENTRA_ID: "ENTRA_ID" }

Type

{ ACCESS_TOKEN: "ACCESS_TOKEN", ENTRA_ID: "ENTRA_ID" }

ServiceEnvironmentVariable

Environment variables used by Microsoft Playwright Testing

ServiceEnvironmentVariable: { PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string, PLAYWRIGHT_SERVICE_EXPOSE_NETWORK_ENVIRONMENT_VARIABLE: string, PLAYWRIGHT_SERVICE_OS: string, PLAYWRIGHT_SERVICE_REPORTING_URL: string, PLAYWRIGHT_SERVICE_URL: string }

Type

{ PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string, PLAYWRIGHT_SERVICE_EXPOSE_NETWORK_ENVIRONMENT_VARIABLE: string, PLAYWRIGHT_SERVICE_OS: string, PLAYWRIGHT_SERVICE_REPORTING_URL: string, PLAYWRIGHT_SERVICE_URL: string }

ServiceOS

OS types supported on Microsoft Playwright Testing cloud hosted browsers

ServiceOS: { LINUX: "linux", WINDOWS: "windows" }

Type

{ LINUX: "linux", WINDOWS: "windows" }