Appearance
はじめてのPlaywright
Playwrightを使って画面打鍵テストを自動化します。
構築
- Playwrightをインストールします:
shell
npm init playwright@latest- (必要に応じて)依存関係をインストールします:
shell
npx playwright install --with-depsまた、VSCode向けの拡張機能Playwright Test for VSCodeが提供されているので、必要に応じてインストールしてください。
テスト実行
- テストを実行します:
shell
npx playwright test- 下記コマンドでブラウザからテスト結果を確認できます:
shell
npx playwright show-report --host 0.0.0.0Tips
テスト失敗時にブラウザでテスト結果を表示する挙動を止める
playwright.config.jsについて、reporterを下記要領で変更してください。
diff
- reporter: "html",
+ reporter: [["html", { open: "never" }]],chromiumインストール
cf. https://playwright.dev/docs/browsers
shell
npx playwright install chromiumChromeインストール
shell
sudo apt update
wget https://dl.google.com/linux/direct/google-chrome-stable_current_arm64.deb
sudo apt install -y ./google-chrome-stable_current_arm64.deb
sudo rm ./google-chrome-stable_current_arm64.debChromeをテスト対象に含めるには、playwright.config.jsに下記を追加します:
js
{
name: "chrome",
use: {
...devices["Desktop Chrome"],
channel: "chrome",
},
},