Azure App Testing の Playwright ワークスペースが GA したので使ってみた
いわさです。
少し前ですが、Azure App Testing というサービスを紹介しました。
このサービスは Microsoft Azure テストソリューションのハブになるサービスで、内容としては Azure Load Testing や Playwright を含むものです。
ただし、ブログ内でも紹介しているのですが Azure の Playwright マネージドサービスは、以前は Microsoft Playwright Testing というものが存在していましたが(現在も「クラシック」として存在している)、Playwright Workspaces という機能が新しく登場しまして、これが GA となりました。
使い方というか概念はほとんど同じなのですが、セットアップのダッシュボードがなかったりちょっと Playwight Testing とは手順が違っています。
今回軽く触ってみたので紹介します。
リソースの作成
リソースの作成自体は Azure App Testing から作成するだけです。
Playwight ワークスペースでは特別なセットアップ不要ですぐにブラウザエンドポイントなどが払い出されまして、そのまま使い始めることができます。
以前よりも楽になったかもしれない。
あとは Playwright 用のコードからエンドポイントを使うだけです。
テストコードを実行してみる
Playwright WorkSpaces 用のサンプルプロジェクトが提供されているので、こちらを使ってみます。
プロジェクト自体は git クローンしてnpm install
するだけですぐ使い始めることができる状態です。
@azure/playwright@latest
への参照が含まれています。
% git clone https://github.com/Azure/playwright-workspaces.git
Cloning into 'playwright-workspaces'...
remote: Enumerating objects: 295, done.
remote: Counting objects: 100% (207/207), done.
remote: Compressing objects: 100% (142/142), done.
remote: Total 295 (delta 101), reused 124 (delta 55), pack-reused 88 (from 1)
Receiving objects: 100% (295/295), 4.00 MiB | 19.15 MiB/s, done.
Resolving deltas: 100% (117/117), done.
% cd playwright-workspaces/samples/playwright-tests
% npm install
added 48 packages, and audited 49 packages in 1s
11 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
%
Playwright Testing のころと同様にPLAYWRIGHT_SERVICE_URL
に先程 Azure ポータルから取得したブラウザーエンドポイントを設定します。
% export PLAYWRIGHT_SERVICE_URL="wss://eastus.api.playwright.microsoft.com/playwrightworkspaces/32188e43-572e-42c2-98a5-0f792a5c0472/browsers"
また、エンドポイントへの接続にあたって Azure の認証情報が必要になるのでaz login
しておきます。
% az login
A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
Retrieving tenants and subscriptions for the selection...
[Tenant and subscription selection]
No Subscription name Subscription ID Tenant
----- ------------------- ------------------------------------ ---------
[1] fuga subscription 1aec8e3d-2d54-45a0-b65a-cfbbc32b479c 既定のディレクトリ
[2] * hoge subscription a50aeedb-979c-428f-8b2d-28974d5e3d3b 既定のディレクトリ
[3] piyo subscription 1ca32f02-1ac0-4f8e-83f5-0216720d3b5a 既定のディレクトリ
The default is marked with an *; the default tenant is '既定のディレクトリ' and subscription is 'hoge subscription' (a50aeedb-979c-428f-8b2d-28974d5e3d3b).
Select a subscription and tenant (Type a number or Enter for no changes):
Tenant: 既定のディレクトリ
Subscription: hoge subscription (a50aeedb-979c-428f-8b2d-28974d5e3d3b)
[Announcements]
With the new Azure CLI login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271236
If you encounter any problem, please open an issue at https://aka.ms/azclibug
[Warning] The login output has been updated. Please be aware that it no longer displays the full list of available subscriptions by default.
あとはテストを実行するだけです。
Running tests using Playwright workspaces
が表示されていますね。Playwright WorkSpaces 上で実行されていることが確認できます。
% npx playwright test --config=playwright.service.config.ts --workers=20
Running tests using Playwright workspaces.
Test run created successfully.
Running 6 tests using 6 workers
6 passed (16.3s)
To open last HTML report run:
npx playwright show-report
ローカルでは通常どおりレポートが確認できます。
Azure ポータル上では何が確認できるでしょうか。
「実行するテスト」メニューを確認してみると、先程実行した履歴が確認できます。
レポートのとおり 6 件(セッション)のテストが実行されていたことが確認できました。
さいごに
本日は Azure App Testing の Playwright ワークスペースが GA したので使ってみました。
Playwright Testing と違ってダッシュボードがないので最初困惑しましたが、エンドポイントをクライアント側で使うという点は同じなので実際に使ってみると難しいことはありませんでした。
Playwright Testing はクラシックという扱いになり、今後は今回 GA した Playwright WorkSpaces の利用が推奨されているようなのでぜひ使ってみてください。