編集

Playwright v1.49 - Aria Snapshots

Playwright v1.49 リリース。

https://playwright.dev/docs/release-notes#version-149

アクセシビリティツリーのスナップショットを取れる Aria Snapshot 機能が追加。 従来の DOM 構造のスナップショットに比べて、リファクタリング耐性が高い。

tsx
await expect(page.locator("body")).toMatchAriaSnapshot("...");

https://playwright.dev/docs/aria-snapshots

#New Chromium

新しいヘッドレス Chromium を選択できるようになった。

次のようにオプトインできる。

tsx
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  projects: [
    {
      name: "chromium",
      use: { ...devices["Desktop Chrome"], channel: "chromium" },
    },
  ],
});

これは Chrome が言及しているもので、本物の Chrome ブラウザを利用することが出来る。

https://developer.chrome.com/blog/chrome-headless-shell?hl=ja

Playwright では、この変更に伴いデフォルトで古いヘッドレス実装と新しいヘッドレス実装の両方がダウンロードされるようになったため、ダウンロードサイズが増加した。

https://github.com/microsoft/playwright/issues/33566

どちらを利用するかに合わせて次のようにオプションを渡すことで最適化できる。

shell
# after for headless-only tests
npx playwright install --only-shell

# after for new headless mode
npx playwright install --no-shell
編集