<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Visual Testing · 仁才徳</title>
    <link>https://jared.lynskey.co.nz/ja/tags/visual-testing/</link>
    <description>ソフトウェアエンジニアリングと開発組織のリーダーシップについて。評価、採用とチームの拡大、CI/CD、DevOps モニタリング、エージェンティック AI。ソウルより。</description>
    <generator>Hugo</generator>
    <language>ja</language>
    <copyright>© 2026 仁才徳</copyright>
    <lastBuildDate>Wed, 28 Oct 2026 00:00:00 +1300</lastBuildDate>
    <atom:link href="https://jared.lynskey.co.nz/ja/tags/visual-testing/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>ビジュアルリグレッションテストをPlaywrightで：小規模チームにこそ効く理由</title>
      <link>https://jared.lynskey.co.nz/ja/posts/2024/2024-06-09-playwright-tests/</link>
      <guid isPermaLink="true">https://jared.lynskey.co.nz/ja/posts/2024/2024-06-09-playwright-tests/</guid>
      <pubDate>Sun, 09 Jun 2024 00:30:03 +0000</pubDate>
      <dc:creator>Jared Lynskey</dc:creator>
      <category>Visual Testing</category>
      <category>Small Teams</category>
      <category>UI Testing</category>
      <category>Playwright</category>
      <description>Playwrightでのビジュアルリグレッションテストについて。スクリーンショット比較が、小さなチームが持てるテストの中でいちばん費用対効果が高い理由をまとめました。</description>
      <content:encoded><![CDATA[<p>CSSを1行変えただけなのに、まったく別のページのボタンが静かに崩れている。テストは何も落ちず、レビューでも気づかれず、1週間後にユーザーからの報告で発覚する。小さなチームなら、誰でも覚えのあるバグだと思います。</p>
<p>教科書的な答えは「ユニットテストを増やしましょう」です。私も少人数の開発チームを見ていますが、正直なところ、すべてのコンポーネントとレイアウト状態にユニットテストを書く余裕はありません。代わりに頼っているのがビジュアルテストです。ページのスクリーンショットを撮り、正常時のベースラインと比較して、動くはずのないピクセルが動いたらビルドで知らせる。かかる手間を考えると、これに匹敵する方法を他に知りません。</p>

<h2 class="relative group">スクリーンショットが働き者である理由
    <div id="スクリーンショットが働き者である理由" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e3%82%b9%e3%82%af%e3%83%aa%e3%83%bc%e3%83%b3%e3%82%b7%e3%83%a7%e3%83%83%e3%83%88%e3%81%8c%e5%83%8d%e3%81%8d%e8%80%85%e3%81%a7%e3%81%82%e3%82%8b%e7%90%86%e7%94%b1" aria-label="アンカー">#</a>
    </span>
    
</h2>
<p>魅力は「書かなくていいもの」の多さです。ビジュアルテストは個々の要素にアサーションを書くのではなく、ページ全体をまとめて判定します。レイアウトのずれ、色の変化、レスポンシブの崩れ、要素の重なり。コードレビューをすり抜けやすく、ユニットテストでカバーしようとすると苦行になるものばかりですが、これらが全部PR上の差分として現れます。</p>
<p>メンテナンスもほぼゼロです。ベースラインを一度設定すれば、あとはPRごとに自動で実行され、毎回同じ結果が返ってきます。意図したUI変更ならベースラインを更新して次へ。意図していない変更なら差分がPRに出ているので、サイトの半分をクリックして回って探す必要はありません。</p>

<h2 class="relative group">ユニットテストの代わりにはなりません
    <div id="ユニットテストの代わりにはなりません" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e3%83%a6%e3%83%8b%e3%83%83%e3%83%88%e3%83%86%e3%82%b9%e3%83%88%e3%81%ae%e4%bb%a3%e3%82%8f%e3%82%8a%e3%81%ab%e3%81%af%e3%81%aa%e3%82%8a%e3%81%be%e3%81%9b%e3%82%93" aria-label="アンカー">#</a>
    </span>
    
</h2>
<p>ユニットテストはロジックを、スクリーンショットは見た目を検証します。最終的には両方欲しいところです。ただ、小さなチームで最初の数時間をどこに使うか選ぶなら、セットアップ時間あたりのカバレッジはビジュアルテストが一番だと思います。私の目安は、壊れると本当に痛いビジネスロジックにはユニットテスト、それ以外はビジュアルテスト、です。</p>
<p>仕組みはこれで全部です。ベースラインと、PRごとの差分と、たまに「はい、これは意図的な変更です」とクリックするだけ。それにしては、よく働いてくれます。</p>

<h2 class="relative group">詳細情報と参考リンク
    <div id="詳細情報と参考リンク" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e8%a9%b3%e7%b4%b0%e6%83%85%e5%a0%b1%e3%81%a8%e5%8f%82%e8%80%83%e3%83%aa%e3%83%b3%e3%82%af" aria-label="アンカー">#</a>
    </span>
    
</h2>

<h3 class="relative group">Visual Testing with Playwright
    <div id="visual-testing-with-playwright" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#visual-testing-with-playwright" aria-label="アンカー">#</a>
    </span>
    
</h3>
<p>Playwrightのスナップショットテストのドキュメント。ページ全体や特定要素をキャプチャしてベースラインと比較する方法と、意図的なUI変更時のベースライン更新の方法がまとまっています。
<a href="https://playwright.dev/docs/test-snapshots"  target="_blank" rel="noreferrer">Visual Testing with Playwright</a></p>

<h3 class="relative group">Best Practices for Testing with Playwright
    <div id="best-practices-for-testing-with-playwright" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#best-practices-for-testing-with-playwright" aria-label="アンカー">#</a>
    </span>
    
</h3>
<p>データベースを扱うテストのためのPlaywrightの推奨事項。テストデータの分離、テスト後のクリーンアップ、テストの独立性の保ち方が解説されています。
<a href="https://playwright.dev/docs/best-practices#testing-with-a-database"  target="_blank" rel="noreferrer">Best Practices for Testing with Playwright</a></p>
]]></content:encoded>
      <media:content url="https://jared.lynskey.co.nz/en/posts/2024/2024-06-09-playwright-tests/featured.jpg" medium="image" type="image/jpeg" />
    </item>
  </channel>
</rss>
