自動テストのレポートのデファクトと言ったらjunit reportなんですよ
すごいよね。いまだにjunit xmlがスタンダード。何年現役なんでしょう。多くのciでもこいつをいい感じに見せるビューを備えてる
Gitlab
junit xmlの出力
playwright.config.ts
のdefineConfig.reporter:Array
に'junit',{outputFile: 'results.xml'}
突っ込むか、npx playwright test --reporter=junit
するか
個人的に設定に書いちゃうのが多いので今回はその例でやる。好み
htmlは個人的に追加でだしてるだけなんでいらんかったら無視で良し
export default defineConfig({ // other setteings reporter: [['junit', { outputFile: 'results.xml' }],["html"]], // other setteings...
gitlab-ci.yml
artifacts
以下が重要。reports書けば各パイプラインのtestsタブにレポートが出るようになる
junit xmlのパスって何?って人はさっきdefineConfigやらに書いたoutputFile
やそのあたりにあるファイルを探してください
stages: - test tests: stage: test image: mcr.microsoft.com/playwright:v1.39.0-jammy script: - npm install @playwright/test - npx playwright test artifacts: reports: junit: results.xml
出力
おまけ mcr.microsoft.com/playwright:v1.39.0-jammy
Microsoftって書いてあるけどおもっきしUbuntuイメージ。playwright公式かつmicrosoft公式。
playwrightとブラウザがインストールされたdockerイメージ。npx playwright installとか省略してるのはこれのおかげ。便利。