The open-source Playwright library for AI browser regression testing with intelligent caching, auto-healing, and multi-model verification.
The open-source Playwright library for AI browser regression testing with intelligent caching, auto-healing, and multi-model verification.
The open-source Playwright library for AI regression testing.
Passmark covers your browser regression testing end-to-end and helps you catch regressions early. Fast.
It uses AI models to execute natural language browser steps via Playwright, with intelligent caching, auto-healing, and multi-model assertion verification. Your tests stay stable without needing to update AI prompts or retrain models.
Passmark is built by Bug0, the team also building FactoryKit, the AI software factory.
npm init playwright@latest passmark-project # select the default options and set language to TypeScript
cd passmark-project
npm install passmarkWe need at least one model from Anthropic and one from Google to use Passmark's multi-model consensus features. Set the required environment variables in .env:
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_GENERATIVE_AI_API_KEY=AIza...Alternatively, you can use an AI gateway like Vercel AI Gateway, OpenRouter, or OpenCode Zen to route requests to multiple providers without managing individual API keys. If you choose this option, set AI_GATEWAY_API_KEY (for Vercel), OPENROUTER_API_KEY (for OpenRouter), or OPENCODEZEN_API_KEY (for OpenCode Zen) instead.
You can also route requests through Cloudflare AI Gateway for observability, caching, and rate limiting. Unlike Vercel/OpenRouter/OpenCode Zen, Cloudflare is a proxy (not a reseller), so you still need your own ANTHROPIC_API_KEY / GOOGLE_GENERATIVE_AI_API_KEY alongside CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AI_GATEWAY (and CLOUDFLARE_AI_GATEWAY_API_KEY if the gateway has authentication enabled).
Set your Playwright project to read .env by adding the following to playwright.config.ts (after import { defineConfig, devices } from '@playwright/test';):
import dotenv from 'dotenv';
import path from 'path';
dotenv.config({ path: path.resolve(__dirname, '.env') });Make sure you install dotenv by running npm install dotenv.
Now, paste the following code into tests/example.spec.ts:
…If you are using an AI gateway, you can add the following to the above code:
import { runSteps, configure } from "passmark";
configure({
ai: {
gateway: "vercel" // or "openrouter", "opencodezen", or "cloudflare"
// Set AI_GATEWAY_API_KEY (Vercel), OPENROUTER_API_KEY (OpenRouter),
// OPENCODEZEN_API_KEY (OpenCode Zen), or
// CLOUDFLARE_ACCOUNT_ID + CLOUDFLARE_AI_GATEWAY (+ CLOUDFLARE_AI_GATEWAY_API_KEY
// if the gateway is authenticated) in your .env file. Cloudflare also requires
// the upstream provider keys (ANTHROPIC_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY).
}
});To run the test, use:
npx playwright test example.spec.ts --project chromiumAfter the test completes, you can run npx playwright show-report to see a detailed report of the test execution, including an AI summary at the top, provided by Passmark.
By default Passmark uses ARIA accessibility snapshots. For visual, screenshot-driven automation via OpenAI's computer-use agent, opt in with mode: "cua":
import { configure } from "passmark";
configure({
ai: {
mode: "cua",
gateway: "none", // CUA requires direct OpenAI access
},
});Set OPENAI_API_KEY in your .env. Then you can write tests like this:
test("Shopping cart tests", async ({ page }) => {
await runSteps({
page,
userFlow: "Add product to cart",
steps: [
{ description: "Navigate to https://demo.vercel.store" },
{ description: "Click Acme Circles T-Shirt" },
{ description: "Select color", data: { value: "White" } },
{ description: "Add to cart", waitUntil: "My Cart is visible" },
],
test,
expect,
});
});Notes:
gpt-5.5 + built-in computer tool. The CUA model is currently locked and not user-configurable.gateway: "vercel" | "openrouter" | "cloudflare" is not compatible with CUA — the Responses-API computer tool is only exposed on direct OpenAI access.computer tool on the Responses API.The same ai shape accepted by configure() can also be passed at the runSteps/runUserFlow call level and on individual Steps. This lets you mix snapshot steps (cheap, cacheable, OpenRouter/Vercel/etc.) with CUA steps (visual, direct OpenAI) in a single run. Precedence: step.ai ▶ call-level ai ▶ global configure().
configure({ ai: { gateway: "openrouter" } }); // most steps go through OpenRouter
await runSteps({
page, test, expect,
userFlow: "Buy product on sale",
steps: [
{ description: "Navigate to /products" }, // OpenRouter snapshot
{
description: "Drag the price slider to $40",
ai: { mode: "cua", gateway: "none" }, // CUA for this step only
},
{ description: "Click Add to cart" }, // back to OpenRouter snapshot
],
});Set OPENAI_API_KEY whenever any step opts into mode: "cua". CUA steps still require gateway: "none"; mixing CUA with a non-none gateway throws at the per-step level for the same reason it does globally.
runSteps() and runUserFlow() for flexible test orchestration in natural language, with smart caching and auto-healing{{run.*}}, {{global.*}}, {{data.*}}, and {{email.*}} expressions for repeatable and data-driven testsconfigure() entry point for models, gateway, email provider, and upload pathRegression risk scales with change volume, and coding agents have multiplied change volume. When a background coding agent like FactoryKit works your backlog, it runs your repo's own checks on every change before a human reviews the pull request; a Passmark suite slots in as exactly that check. Because steps are written in natural language and auto-heal, the suite keeps passing while the agent reshapes the DOM underneath it, which is where selector-based tests usually give up.
runSteps(options: RunStepsOptions)Executes a sequence of steps using AI with caching. Each step is described in natural language and executed via Playwright.
await runSteps({
page,
userFlow: "Checkout Flow",
steps: [
{ description: "Add item to cart" },
{ description: "Go to checkout" },
{ description: "Fill in shipping details", data: { value: "123 Main St" } },
],
assertions: [{ assertion: "Order confirmation is displayed" }],
test,
expect,
});runUserFlow(options: UserFlowOptions)Runs a complete user flow as a single AI agent call. Best for exploratory testing where exact steps are flexible.
const result = await runUserFlow({
page,
userFlow: "Complete a purchase",
steps: "Navigate to store, add an item, checkout with test card",
effort: "high", // by default "low" uses gemini-3-flash for faster execution; "high" uses gemini-3.1-pro-preview for deeper thinking
});assert(options: AssertionOptions)Multi-model consensus assertion. Runs Claude and Gemini in parallel; if they disagree, a third model arbitrates (configurable — see Consensus Policy).
const result = await assert({
page,
assertion: "The dashboard shows 3 active projects",
expect,
});When the primary (Claude) and secondary (Gemini) assertion models reach the same verdict, the result is used directly. When they disagree, you choose how Passmark resolves it:
| Policy | Behavior |
|---|---|
consult-arbiter-on-disagreement (default) |
Calls the arbiter model (Gemini 3.1 Pro) to break the tie. |
fail-on-disagreement |
Treats any disagreement as a failure immediately — no arbiter call. The returned reasoning includes both models' takes so you can inspect what they saw differently. |
Pick fail-on-disagreement when you'd rather surface ambiguity/flakiness in the UI under test than let a single model swing the result. Pick the default when you trust the arbiter to make the final call.
configure({
assertions: {
consensusPolicy: "fail-on-disagreement",
},
});For UI that's only visible for a second or two — toast messages, snackbar confirmations, transient banners — a single end-of-flow screenshot often misses the evidence. Set video: true on an assertion inside runSteps and Passmark will record the entire step run with page.screencast, upload the resulting .webm to Gemini's Files API, and evaluate the assertion against the full video:
await runSteps({
page,
userFlow: "Add to cart",
steps: [
{ description: "Click Acme Circles T-Shirt" },
{ description: "Add to cart" },
],
assertions: [
{ assertion: "An 'Added to cart' toast appears", video: true },
],
test,
expect,
});Notes:
video: true assertions in the same runSteps call./tmp/passmark-recordings/ by default and deleted automatically after the assertions consume it. Override via configure({ videoDir: "/your/path" }).gemini-3-flash-preview.gateway — file URIs are tied to the uploading Google account, so the gateway can't proxy them. You must set GOOGLE_GENERATIVE_AI_API_KEY (or GEMINI_API_KEY) even when the rest of your stack runs through Vercel / OpenRouter / Cloudflare.page.screencast.start() fails (rare), video assertions silently fall back to the regular screenshot/snapshot path so the run still completes.Call configure() once before using any functions:
import { configure } from "passmark";
configure({
ai: {
gateway: "none", // "none" (default), "vercel", "openrouter", "opencodezen", or "cloudflare"
models: {
stepExNo open issues yet, or sync has not completed.