フロントエンド開発の先端を突っ走るNext.js
next.js アプリの初期化( npx create-next-app@latest <アプリ名> ) または pnpm create next-app@latest <アプリ名> または bun create next-app <アプリ名> )

next.js 16.3 で データ取得前の状態をテストしやすくなった

● next.js 16.3 で データ取得前の状態をテストしやすくなった

Next.js 16.3では、Playwright向けの Playwright Test Helper が追加されました。

これを使うと、Instant Navigation の状態をE2Eテストで検証できます。

インストール

npm install -D @next/playwright

利用例

import { instant } from "@next/playwright";

await instant(page, async () => {
  await page.click('a[href="/profile"]');
  await expect(page.getByTestId("profile-name")).toBeVisible();
});

instant() の中では、サーバーデータの取得完了を待たず、キャッシュ済みの画面(Shell)の状態をテストできます。

これまで確認しづらかった「クリック直後の画面」を簡単に検証できるようになりました。

No.2767
08/04 15:24

edit