|
| 1 | +--- |
| 2 | +title: Microsoft Playwright Testing service configuration file options |
| 3 | +description: Learn how to use options available in configuration file with Microsoft Playwright Testing preview |
| 4 | +ms.topic: how-to |
| 5 | +ms.date: 09/07/2024 |
| 6 | +ms.custom: playwright-testing-preview |
| 7 | +--- |
| 8 | +# Use options available in configuration file with Microsoft Playwright Testing preview |
| 9 | + |
| 10 | +This article shows you how to use the options available in the `playwright.service.config.ts` file that was generated for you. |
| 11 | +If you don't have this file in your code, follow the QuickStart guide, see [Quickstart: Run end-to-end tests at scale with Microsoft Playwright Testing Preview](./quickstart-run-end-to-end-tests.md) |
| 12 | + |
| 13 | +> [!IMPORTANT] |
| 14 | +> Microsoft Playwright Testing is currently in preview. For legal terms that apply to Azure features that are in beta, in preview, or otherwise not yet released into general availability, see the [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/). |
| 15 | +
|
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +* Follow the Quickstart guide and set up a project to run with Microsoft Playwright Testing service. See, [Quickstart: Run end-to-end tests at scale with Microsoft Playwright Testing Preview](./quickstart-run-end-to-end-tests.md) |
| 19 | + |
| 20 | +Here's version of the `playwright.service.config.ts` file with all the available options: |
| 21 | + |
| 22 | +```typescript |
| 23 | +import { getServiceConfig, ServiceOS } from "@azure/microsoft-playwright-testing"; |
| 24 | +import { defineConfig } from "@playwright/test"; |
| 25 | +import { AzureCliCredential } from "@azure/identity"; |
| 26 | +import config from "./playwright.config"; |
| 27 | + |
| 28 | +export default defineConfig( |
| 29 | + config, |
| 30 | + getServiceConfig(config, { |
| 31 | + serviceAuthType:'ACCESS_TOKEN' // Use this option when you want to authenticate using access tokens. This mode of auth should be enabled for the workspace. |
| 32 | + os: ServiceOS.WINDOWS, // Select the operating system where you want to run tests. |
| 33 | + runId: new Date().toISOString(), // Set a unique ID for every test run to distinguish them in the service portal. |
| 34 | + credential: new AzureCliCredential(), // Select the authentication method you want to use with Entra. |
| 35 | + useCloudHostedBrowsers: true, // Select if you want to use cloud-hosted browsers to run your Playwright tests. |
| 36 | + exposeNetwork: '<loopback>', // Use this option to connect to local resources from your Playwright test code without having to configure additional firewall settings. |
| 37 | + timeout: 30000 // Set the timeout for your tests. |
| 38 | + }), |
| 39 | + { |
| 40 | + reporter: [ |
| 41 | + ["list"], |
| 42 | + [ |
| 43 | + "@azure/microsoft-playwright-testing/reporter", |
| 44 | + { |
| 45 | + enableGitHubSummary: true, // Enable/disable GitHub summary in GitHub Actions workflow. |
| 46 | + }, |
| 47 | + ], |
| 48 | + ], |
| 49 | + }, |
| 50 | +); |
| 51 | + |
| 52 | +``` |
| 53 | + |
| 54 | +## Settings in `playwright.service.config.ts` file |
| 55 | + |
| 56 | +* **`serviceAuthType`**: |
| 57 | + - **Description**: This setting allows you to choose the authentication method you want to use for your test run. |
| 58 | + - **Available Options**: |
| 59 | + - `ACCESS_TOKEN` to use access tokens. You need to enable authentication using access tokens if you want to use this option, see [manage authentication](./how-to-manage-authentication.md). |
| 60 | + - `ENTRA_ID` to use Microsoft Entra ID for authentication. It's the default mode. |
| 61 | + - **Default Value**: `ENTRA_ID` |
| 62 | + - **Example**: |
| 63 | + ```typescript |
| 64 | + serviceAuthType:'ENTRA_ID' |
| 65 | + ``` |
| 66 | + |
| 67 | + |
| 68 | +* **`os`**: |
| 69 | + - **Description**: This setting allows you to choose the operating system where the browsers running Playwright tests are hosted. |
| 70 | + - **Available Options**: |
| 71 | + - `ServiceOS.WINDOWS` for Windows OS. |
| 72 | + - `ServiceOS.LINUX` for Linux OS. |
| 73 | + - **Default Value**: `ServiceOS.LINUX` |
| 74 | + - **Example**: |
| 75 | + ```typescript |
| 76 | + os: ServiceOS.WINDOWS |
| 77 | + ``` |
| 78 | + |
| 79 | +* **`runId`**: |
| 80 | + - **Description**: This setting allows you to set a unique ID for every test run to distinguish them in the service portal. |
| 81 | + - **Example**: |
| 82 | + ```typescript |
| 83 | + runId: new Date().toISOString() |
| 84 | + ``` |
| 85 | + |
| 86 | +* **`credential`**: |
| 87 | + - **Description**: This setting allows you to select the authentication method you want to use with Microsoft Entra ID. |
| 88 | + - **Example**: |
| 89 | + ```typescript |
| 90 | + credential: new AzureCliCredential() |
| 91 | + ``` |
| 92 | + |
| 93 | +* **`useCloudHostedBrowsers`** |
| 94 | + - **Description**: This setting allows you to choose whether to use cloud-hosted browsers or the browsers on your client machine to run your Playwright tests. If you disable this option, your tests run on the browsers of your client machine instead of cloud-hosted browsers, and you don't incur any charges. |
| 95 | + - **Default Value**: true |
| 96 | + - **Example**: |
| 97 | + ```typescript |
| 98 | + useCloudHostedBrowsers: true |
| 99 | + ``` |
| 100 | + |
| 101 | +* **`exposeNetwork`** |
| 102 | + - **Description**: This setting allows you to connect to local resources from your Playwright test code without having to configure another firewall settings. To learn more, see [how to test local applications](./how-to-test-local-applications.md) |
| 103 | + - **Example**: |
| 104 | + ```typescript |
| 105 | + exposeNetwork: '<loopback>' |
| 106 | + ``` |
| 107 | + |
| 108 | +* **`timeout`** |
| 109 | + - **Description**: This setting allows you to set timeout for your tests connecting to the cloud-hosted browsers. |
| 110 | + - **Example**: |
| 111 | + ```typescript |
| 112 | + timeout: 30000, |
| 113 | + ``` |
| 114 | + |
| 115 | +* **`reporter`** |
| 116 | + - **Description**: The `playwright.service.config.ts` file extends the playwright config file of your setup. This option overrides the existing reporters and sets Microsoft Playwright Testing reporter. You can add or modify this list to include the reporters that you want to use. You're billed for Microsoft Playwright Testing reporting if you add `@azure/microsoft-playwright-testing/reporter`. |
| 117 | + - **Default Value**: ["@azure/microsoft-playwright-testing/reporter"] |
| 118 | + - **Example**: |
| 119 | + ```typescript |
| 120 | + reporter: [ |
| 121 | + ["list"], |
| 122 | + ["@azure/microsoft-playwright-testing/reporter"], |
| 123 | + ``` |
| 124 | +* **`enableGitHubSummary`**: |
| 125 | + - **Description**: This setting allows you to configure the Microsoft Playwright Testing service reporter. You can choose whether to include the test run summary in the GitHub summary when running in GitHub Actions. |
| 126 | + - **Default Value**: true |
| 127 | + - **Example**: |
| 128 | + ```typescript |
| 129 | + reporter: [ |
| 130 | + ["list"], |
| 131 | + [ |
| 132 | + "@azure/microsoft-playwright-testing/reporter", |
| 133 | + { |
| 134 | + enableGitHubSummary: true, |
| 135 | + }, |
| 136 | + ], |
| 137 | + ] |
| 138 | + ``` |
| 139 | + |
0 commit comments