[[Playwright]]のVersion 1.51に気になる機能がいくつかあったので確認する。 ## プロジェクトセットアップ ```bash toki playwright playwright-sandbox ``` ## Test Step improvements [[TestStepInfo (Playwright)|TestStepInfo]]が取得できるようになった。 ### attachmentの追加 v1.51.1で一番使えそうな機能。 ```ts test("get started link", async ({ page }) => { await page.goto("https://playwright.dev/"); await page.getByRole("link", { name: "Get started" }).click(); await test.step("attachment step", async (step) => { await step.attach("ファイルパスを指定", { path: "./package.json", }); await step.attach("bodyを指定", { body: JSON.stringify(page.keyboard, null, 2), contentType: "application/json", }); }); await expect(page.getByRole("heading", { name: "hoge" })).toBeVisible(); }); ``` 以下のようになる。 ![[Pasted image 20250419153455.png]] [[Trace Viewer]]ではファイルパス指定でも中身が見られるようになってる。(1回目開いたときはダメだったので少し時間がいるのかも?) ![[Pasted image 20250419153719.png]] ### stepのスキップ ```ts test("get started link", async ({ page }) => { await page.goto("https://playwright.dev/"); await page.getByRole("link", { name: "Get started" }).click(); await test.step("skip step", async (step) => { // ここでスキップ step.skip(); // 以下は実行されない await expect(page.getByRole("heading", { name: "hoge" })).toBeVisible(); }); }); ``` ## Git information in HTML report 現時点の[[Git]]情報をレポートに出力する設定。 ```ts { captureGitInfo: { commit: true, diff: true }, } ``` これだけだとそこまで恩恵はない気がする。 ### 設定前 ![[Pasted image 20250419151031.png]] ### 設定後 ![[Pasted image 20250419151402.png]]