pickstack

Next.js + Playwright

End-to-end tests in a real browser (Chromium). This page shows exactly what pickstack adds to a Next.js project for Playwright: the packages, the new files and the changes to existing ones. Every combination is installed, built, linted and tested in CI.

$ npm create pickstack@latest my-app -- --framework next --modules playwright --yes
Customize in the configurator

Packages it adds

PackageVersionType
@playwright/test^1.65.1dev

New files

e2e/app.e2e.ts
import { expect, test } from "@playwright/test";

test("the counter goes up", async ({ page }) => {
  await page.goto("/");
  // Clicks before hydration are lost, so retry until the count changes.
  await expect(async () => {
    await page.getByRole("button", { name: "+1" }).click();
    await expect(page.getByText("1", { exact: true })).toBeVisible({
      timeout: 1000,
    });
  }).toPass();
});

test("the about page opens from the nav", async ({ page }) => {
  await page.goto("/");
  await page.getByRole("link", { name: "About" }).click();
  await expect(page).toHaveURL(/about/);
  await expect(page.getByRole("heading", { name: "About" })).toBeVisible();
});
playwright.config.ts
import process from "node:process";
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./e2e",
  testMatch: "**/*.e2e.?(c|m)[jt]s",
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  reporter: "html",
  use: { baseURL: "http://localhost:3000", trace: "on-first-retry" },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
  webServer: {
    command: "npm run dev",
    url: "http://localhost:3000",
    reuseExistingServer: !process.env.CI,
  },
});

Changes to existing files

.gitignore (changed)
⋯ 3 unchanged lines out next-env.d.ts *.tsbuildinfo+/test-results/+/playwright-report/+/blob-report/+/playwright/.cache/ .env .env.local .DS_Store⋯ 1 unchanged lines
app/about/page.tsx (changed)
⋯ 2 unchanged lines     <section className="page">       <h1 className="title">About</h1>       <p className="text">+        Built with Next.js (App Router), React 19, TypeScript, Playwright.−        Built with Next.js (App Router), React 19, TypeScript.       </p>     </section>   );⋯ 2 unchanged lines

Project files

Related templates