GuidesEnd-to-end testing
Set up a Playwright suite
Create a Playwright suite from scratch, write your first real user-flow test, and run it on every pull request.
Playwright is the world's most popular open-source end-to-end testing framework. You write TypeScript code that drives a real browser and exercises your application the same way a user would.
By the end of this guide, you will have one real user-flow test in a new Playwright suite, running automatically on every pull request:


Pick one flow you would be embarrassed to break
Most tutorials start with a smoke test that loads / and checks for a heading. That proves Playwright can open a browser, not that your product works.
Pick one flow you would be embarrassed to break. In BikeBook, our example bike-booking app, a great starter flow is:
- Sign up as a new user
- Add a new bike to the office fleet
- Book that bike for the morning
Here is a replay of that passing test running on Endform:
Set up your suite
You need Node.js 24 or newer, an application URL to test (your own app, or our hosted BikeBook app at https://endform-playwright-guides.vercel.app), an AI_GATEWAY_API_KEY for generating steps locally, and a GitHub repository. Endform itself needs Node.js 22.15 or newer, but Playwright Intent needs 24.
-
Initialize Playwright, Playwright Intent and Endform
Scaffold a new Playwright suite, set up Playwright Intent, and connect the suite to Endform:
npm init playwright@latest npm init playwright-intent@latest npm init endform@latestpnpm create playwright pnpm create playwright-intent pnpm create endformyarn create playwright yarn create playwright-intent yarn create endformnpm init endformsigns you in and runs the example test on Endform.await ai.do("book Road 1 for the morning");Converts at runtime into reviewable Playwright code:
await page.getByRole("button", { name: "Book Road 1 morning" }).click(); await expect(page.getByRole("status")).toContainText("Booked Road 1");Playwright Intent invokes a model of your choosing at runtime to convert natural language into reviewable Playwright code artifacts. By default, those conversions are stored in your GitHub repository under
.intent/, though they can also be stored remotely.The model only runs on the first run and when a cached step fails. Most runs never call an agent and execute straight from the stored cache.
Set
use.baseURLinplaywright.config.tsto your app URL (orhttps://endform-playwright-guides.vercel.appto try BikeBook). Click any file below to expand its contents:Folder structure created by initialization5 files+50import fs from "node:fs";import path from "node:path";import { defineConfig, devices } from "@playwright/test";import type { IntentOptions, IntentUseOptions } from "playwright-intent";import { allow, fileStore, refuse } from "playwright-intent/file-store"; const envFile = path.join(__dirname, ".env");if (fs.existsSync(envFile)) process.loadEnvFile(envFile); const intent = { model: "openai/gpt-6-luna", store: fileStore({ updates: { local: allow(), ci: refuse() } }),} satisfies IntentOptions; export default defineConfig<IntentUseOptions>({ testDir: "./tests", fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, reporter: [["html"], ["playwright-intent/reporter", intent]], use: { intent, baseURL: process.env.BASE_URL || "https://endform-playwright-guides.vercel.app", trace: "on-first-retry", }, projects: [ { name: "chromium", use: { ...devices["Desktop Chrome"] }, }, ],});import { expect, test } from "playwright-intent"; test("has title", async ({ page }) => { await page.goto("https://playwright.dev/"); await expect(page).toHaveTitle(/Playwright/);});AI_GATEWAY_API_KEY=your-key-herenode_modules/.env/test-results//playwright-report/{ "devDependencies": { "@playwright/test": "^1.65.0", "playwright-intent": "^0.3.0" }} -
Write your first test
Replace
tests/example.spec.tswithtests/book-a-bike.spec.ts(or your own core user flow). Hover or click anai.do(...)step to inspect the compiled Playwright code:tests/book-a-bike.spec.tsimport { expect, test } from "playwright-intent"; test("a new user can sign up, add a bike, and book it", async ({ page, ai,}) => { const email = `user-${Date.now()}-${Math.random().toString(36).slice(2, 8)}@example.com`; await page.goto("/sign-up"); await expect(page.getByRole("status")).toContainText("Booked Road 1"); await expect( page.getByRole("listitem").filter({ hasText: "Road 1" }), ).toContainText("morning");}); -
Run it on Endform
npx endform@latest testOn the first run, Playwright Intent uses your configured model to generate a reviewable
.intent/TypeScript file for eachai.do(...)step. Commit.intent/alongside your test so future runs execute deterministically from the cache without calling a model.Here is today's scheduled run of this test in Endform:
1 test · clean appBaseline BikeBook suite run -
Run it on every pull request
Add
.github/workflows/e2e.yml(or replace the workflow created by Playwright) so every pull request runs your suite on Endform:.github/workflows/e2e.yml name: End-to-end tests on: pull_request: branches: [main] permissions: contents: read id-token: write jobs: e2e: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 24 - run: npm ci - run: npx endform@latest test env: BASE_URL: ${{ vars.STAGING_URL }}For CI authentication, other providers, or testing per-PR preview deployments, see Set up Endform in CI, Test Vercel previews, and Test Netlify Deploy Previews. If you are testing a local dev server, see Test against a local server.
Cover your core product domains in 10 tests and remove repeated UI sign-up with programmatic users.
Set up Endform in CIConfigure CI authentication and reporting across GitHub Actions and other providers.
Test Vercel previewsWait for each pull request's preview URL and test every change before merge.
Last updated