write-tests-e2e

A set of rules for writing end-to-end tests, which check complete user journeys in a real browser against the backend, database, and frontend together.

In plain words
What is it for?
Use it when writing Playwright tests for login, navigation, and other browser-visible workflows, including choosing stable selectors and waiting for rendered content.
Why use it?
It helps avoid tests that hang or pass for the wrong reason, especially in single-page apps where page content changes without a full reload.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/golid-ai/golid/write-tests-e2e
Clone the repo
git clone --depth 1 https://github.com/golid-ai/golid

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,034 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01034
Opus 5 $0.00000 $0.00517
Sonnet 5 $0.00000 $0.00207
Haiku 4.5 $0.00000 $0.00103

Measured 2d ago against content hash 85a41d8be1b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

write-tests-e2e scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/write-tests-e2e.mdc · 144 lines

How it starts

The opening of the file, as written. The whole thing — 144 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing E2E Tests

Thesis: E2E tests verify browser-visible user journeys against the full stack, so they wait for rendered UI, use stable role selectors, and run serially against shared state.

E2E tests live in frontend/tests/e2e/. They require the full stack running (backend + DB + frontend).

SPA Navigation: Wait for Page Content

SolidJS uses client-side routing (pushState). Playwright's waitForURL waits for a browser load event that never fires during SPA navigation. Always wait for page content instead.

// BAD: hangs forever on SPA navigation
await page.click('button[type="submit"]');
await page.waitForURL("**/dashboard", { timeout: 15000 });

// GOOD: waits for actual rendered content
await page.click('button[type="submit"]');
await expect(page.getByRole("heading", { name: "Dashboard" })).toBeVisible({
  timeout: 15000,
});

Login Verification

The login page shows "Welcome back" as its heading. Never use /welcome/i to verify login succeeded because it matches the login page before login completes.

// BAD: matches the login page itself
await expect(page.getByText(/welcome/i)).toBeVisible();

// GOOD: "Dashboard" h1 only exists after successful login
await expect(page.getByRole("heading", { name: "Dashboard" })).toBeVisible({
  timeout: 15000,
});

Selectors

When text appears in multiple elements, use role-based selectors:

// BAD: "Golid" appears in navbar, h1, and footer
await expect(page.getByText("Golid")).toBeVisible();

// GOOD: targets the specific heading
await expect(page.getByRole("heading", { name: "Golid" })).toBeVisible();

When a heading and button share text, target the button role:

// BAD: may click the h2 heading instead of the button
await page.click("text=Change Password");

// GOOD
await page.getByRole("button", { name: "Change Password" }).click();

Playwright has no getByDisplayValue. Use locator + toHaveValue:

await expect(page.locator("#email")).toHaveValue("[email protected]");

Read the full file on GitHub · 144 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 144 lines · 0 tokens per session scan A 85a41d8be1b4

Subscribe to this mod's changes

write-tests-e2e is a cursor rule published in the GitHub repository golid-ai/golid (40 stars, last pushed 2mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,034 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.