agentleFS
fugazifugazi/playwright-automation-shop-app/AGENTS.md

playwright-automation-shop-app

AGENTS.md4 starsChanged 13 days agoMITView on GitHub

This document provides essential information for AI coding agents working in this Playwright TypeScript test automation repository.

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository5 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

10 rules. About 0 are common, 3 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No explicit linting: Follow Playwright best practices and TypeScript strict mode

    line 43
  2. Very specific:

    Use web-first assertions with await: await expect(locator).toHaveText()

    line 113
  3. Very specific:

    Prefer toHaveText() over toContainText() for exact matches

    line 114
  4. Very specific:

    Use toMatchAriaSnapshot() for accessibility tree verification

    line 115
  5. Very specific:

    Use toHaveCount() for element counts

    line 116
  6. Very specific:

    Use toHaveURL() for navigation verification

    line 117
  7. Very specific:

    Use expect().toPass() for flaky assertions with retries

    line 126
  8. Distinctive:

    Use JSDoc for public methods in Page Objects

    line 130
  9. Very specific:

    Add section dividers in Page Objects: // ── Section Name ───

    line 131
  10. Distinctive:

    Keep test titles descriptive enough to minimize inline comments

    line 133

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agent Guidelines for Playwright Automation Shop

This document provides essential information for AI coding agents working in this Playwright TypeScript test automation repository.

Project Overview

Build/Test/Lint Commands

# Run all tests (headless)
npx playwright test

# Run a single test file
npx playwright test tests/e2e/auth/login.spec.ts

# Run tests matching a pattern
npx playwright test --grep "login"

# Run tests by tag
npx playwright test --grep @smoke
npx playwright test --grep @regression

# Run with visible browser (headed mode)
npx playwright test --headed

# Debug mode (opens Playwright Inspector)
npx playwright test --debug

# View HTML report
npx playwright show-report

Code Style Guidelines

TypeScript Configuration

  • Target: ESNext with NodeNext module resolution
  • Strict mode: Enabled
  • No explicit linting: Follow Playwright best practices and TypeScript strict mode

Import Conventions

// Tests: Import from custom test base
import { test, expect } from '../fixtures/test-base';

// Page Objects: Import type-only for Locator/Page
import { type Locator, type Page } from '@playwright/test';

// Data: Use named imports
import { CUSTOMER_USER, ADMIN_USER } from '../../data/users.data';

Locator Strategy (Priority Order)

  1. Role-based (preferred): page.getByRole('button', { name: 'Submit' })
  2. Label/Text: page.getByLabel('Email'), page.getByText('Welcome')
  3. Test IDs: page.getByTestId('submit-button')
  4. AVOID: CSS selectors (.btn-primary) and XPath

Naming Conventions

  • Test files: <feature>.spec.ts (e.g., login.spec.ts)
  • Page Objects: <page>.page.ts with PascalCase class names
  • Fixtures: <name>.fixture.ts
  • Data files: <name>.data.ts
  • Constants: UPPER_SNAKE_CASE (e.g., ADMIN_USER)
  • Methods: camelCase with descriptive verbs (e.g., goto(), login())

Page Object Model Pattern

export class LoginPage extends BasePage {
  // Use getters for locators
  get emailInput(): Locator {
    return this.page.getByRole('textbox', { name: 'Email' });
  }

  // Fluent interface - return this for chaining
  async goto(): Promise<this> {
    return this.navigateTo('/login');
  }

  // Actions are async methods
  async login(email: string, password: string): Promise<void> {
    await this.emailInput.fill(email);
    await this.passwordInput.fill(password);
    await this.signInButton.click();
  }
}

Test Structure

test.describe('Feature Name @smoke', () => {
  test.beforeEach(async ({ loginPage }) => {
    await loginPage.goto();
  });

  test('Descriptive test name', async ({ loginPage, page }) => {
    await test.step('Action description', async () => {
      await loginPage.login(CUSTOMER_USER.email, CUSTOMER_USER.password);
    });

    await test.step('Verification', async () => {
      await expect(page).toHaveURL('/');
    });
  });
});

Assertions

  • Use web-first assertions with await: await expect(locator).toHaveText()
  • Prefer toHaveText() over toContainText() for exact matches
  • Use toMatchAriaSnapshot() for accessibility tree verification
  • Use toHaveCount() for element counts
  • Use toHaveURL() for navigation verification

Test Tags

  • @smoke - Critical path tests (20 tests)
  • @regression - Full test suite (121 tests)
  • @a11y - Accessibility tests (14 tests)

Error Handling

  • Rely on Playwright's auto-waiting; avoid hard-coded waits
  • Use expect().toPass() for flaky assertions with retries
  • Let assertions fail naturally; don't catch errors unless testing error scenarios

Comments & Documentation

  • Use JSDoc for public methods in Page Objects
  • Add section dividers in Page Objects: // ── Section Name ───
  • Comments should explain WHY, not WHAT
  • Keep test titles descriptive enough to minimize inline comments

Project Structure

tests/
├── e2e/               # Test specs organized by feature
│   ├── auth/
│   ├── cart/
│   ├── products/
│   └── ...
├── pages/             # Page Object Model classes
├── fixtures/          # Custom Playwright fixtures
├── data/              # Test data (users, products, etc.)
└── helpers/           # Utility functions

VSCode Integration

The project has MCP server configuration for Playwright tools in .vscode/mcp.json.

Key Files to Reference

  • playwright.config.ts - Test configuration
  • tests/fixtures/test-base.ts - Central test fixture export
  • tests/pages/base.page.ts - Base Page Object class
  • .github/instructions/playwright-typescript.instructions.md - Detailed test writing guidelines

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.