Azure App Testing の Playwright ワークスペースでレポート機能を有効化し、Azure Blob ストレージにテスト結果などを自動アップロードできるようになりました
いわさです。
Azure App Testing を使うと、Azure 上に Playwright のマネージドな API エンドポイントを用意して利用することが出来ます。
先日のアップデートで「レポート機能」が追加されました。
今までも Playwright のローカルテストレポートは当然使えていたのですが、今回の機能を有効化すると Azure ストレージアカウントに自動でテストアーティファクトやレポートをアップロードできるようになります。
使ってみたので紹介します。
有効化
Azure App Testing の既存の Playwright ワークスペースを見てみると、レポートの設定が確認できます。
既存ワークスペースは「無効」になっていました。

新規ワークスペースの場合はデフォルトで有効になっており、以下から設定ができます。

既存ワークスペースの場合は以下から有効化が出来ました。ストレージ構成メニューです。

有効化の際には Azure ストレージアカウントを指定する必要があります。


設定した後に気がついたのですが、このレポート設定は有効化した後に無効化は出来ないみたいです。
無効化されているワークスペースの有効化は出来ましたが。

レポート出力
では実際にテストを実行してレポート出力してみましょう。
次のように defineConfig に reporter 設定を追加します。
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['html'],
['@azure/playwright/reporter']
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
:
そしてテストを実行してみましょう。
% npx playwright test --config=playwright.service.config.ts --workers=20
Running tests using Playwright workspaces.
Test run created successfully.
Playwright Workspaces reporting: ENABLED
Collecting artifacts: screenshots, videos, traces.
Uploading artifacts to: storage account= pwhoge0814test98cc, storage container= 32188e43-572e-42c2-98a5-0f792a5c0472, folder= f635a70e-c8b1-4b03-9728-a8a78cca6f0f
Reporting upload status: SUCCESS
Published report URL: https://ms.portal.azure.com/#@microsoft.onmicrosoft.com/resource/subscriptions/a50aeedb-979c-428f-8b2d-28974d5e3d3b/resourceGroups/hoge0814test/providers/Microsoft.LoadTestService/playwrightWorkspaces/hoge0814playwright/TestRuns
To open last HTML report run:
npx playwright show-report
上記メッセージから、ストレージアカウントにレポートがアップロードされていそうなことがわかりますね。
Azure ポータル上で確認してみると次のようにレポートを確認することが出来ました。

なお、この機能を使うためには Playwright のバージョンが 1.57 以上である必要があって、ローカルテスト実行環境が古いと次のようなメッセージが表示されます。
テストは完了しますがレポートアップロードはされないので注意してください。
Running tests using Playwright workspaces.
Test run created successfully.
To use the Playwright Workspaces reporting feature, you need Playwright version 1.57 or later installed. Update the Playwright package to a supported version and try again.
さいごに
本日は Azure App Testing の Playwright ワークスペースでレポート機能を有効化し、Azure Blob ストレージにテスト結果などを自動アップロードできるようになったので使ってみました。
Playwright ワークスペースを使っている方はぜひ試してみてください。
Azure ストレージアカウントの料金が発生するのでそこだけ気をつけましょう。






