Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
sergiodxa avatar

Frontend Testing Best Practices

  • 1.9k installs
  • 93 repo stars
  • Updated February 1, 2026
  • sergiodxa/agent-skills

frontend-testing-best-practices is an agent skill that Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing behavior ove.

About

Guidelines for writing effective maintainable tests that provide real confidence Contains 6 rules focused on preferring E2E tests minimizing mocking and testing behavior over implementation 1 Prefer E2E tests over unit tests Test the whole system not isolated pieces 2 Minimize mocking If you need complex mocks write an E2E test instead 3 Test behavior not implementation Test what users see and do 4 Avoid testing React components directly Test them through E2E Deciding what type of test to write Writing new E2E or unit tests Reviewing test code Refactoring tests prefer e2e tests rules prefer e2e tests md Default to E2E tests Only write unit tests for pure functions The frontend testing best practices agent skill provides documented workflows prerequisites triggers and safety guidance from its SKILL md source Agents load it when user requests match the description and follow step by step instructions without inventing capabilities It integrates with standard agent tooling for the tasks inputs outputs and failure modes described in the repository documentation

  • name: frontend-testing-best-practices
  • description: Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing
  • Guidelines for writing effective, maintainable tests that provide real confidence. Contains 6 rules focused on preferrin
  • Follow frontend-testing-best-practices SKILL.md steps and documented constraints.
  • Follow frontend-testing-best-practices SKILL.md steps and documented constraints.

Frontend Testing Best Practices by the numbers

  • 1,902 all-time installs (skills.sh)
  • +18 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #665 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
At a glance

frontend-testing-best-practices capabilities & compatibility

Capabilities
name: frontend testing best practices · description: testing best practices for the fron · guidelines for writing effective, maintainable t · follow frontend testing best practices skill.md
Use cases
orchestration
From the docs

What frontend-testing-best-practices says it does

name: frontend-testing-best-practices
SKILL.md
description: Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing behavior over implementation details. Use when writing tests or reviewing test
SKILL.md
Guidelines for writing effective, maintainable tests that provide real confidence. Contains 6 rules focused on preferring E2E tests, minimizing mocking, and testing behavior over implementation.
SKILL.md
npx skills add https://github.com/sergiodxa/agent-skills --skill frontend-testing-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1.9k
repo stars93
Security audit3 / 3 scanners passed
Last updatedFebruary 1, 2026
Repositorysergiodxa/agent-skills

When should an agent use frontend-testing-best-practices and what problem does it solve?

Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing behavior over implementation details. Use when writing tests or reviewing test code.

Who is it for?

Developers invoking frontend-testing-best-practices as documented in the skill source.

Skip if: Skip when requirements fall outside frontend-testing-best-practices documented scope.

When should I use this skill?

Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing behavior over implementation details. Use when writing tests or reviewing test code.

What you get

Outputs aligned with the frontend-testing-best-practices SKILL.md workflow and stated deliverables.

  • E2E test strategy
  • user-flow test cases
  • anti-pattern documentation

By the numbers

  • Tagged HIGH impact in skill metadata

Files

SKILL.mdMarkdownGitHub ↗

Testing Best Practices

Guidelines for writing effective, maintainable tests that provide real confidence. Contains 6 rules focused on preferring E2E tests, minimizing mocking, and testing behavior over implementation.

Core Philosophy

1. Prefer E2E tests over unit tests - Test the whole system, not isolated pieces 2. Minimize mocking - If you need complex mocks, write an E2E test instead 3. Test behavior, not implementation - Test what users see and do 4. Avoid testing React components directly - Test them through E2E

When to Apply

Reference these guidelines when:

  • Deciding what type of test to write
  • Writing new E2E or unit tests
  • Reviewing test code
  • Refactoring tests

Rules Summary

Testing Strategy (CRITICAL)

prefer-e2e-tests - @rules/prefer-e2e-tests.md

Default to E2E tests. Only write unit tests for pure functions.

// E2E test (PREFERRED) - tests real user flow
test("user can place an order", async ({ page }) => {
  await createTestingAccount(page, { account_status: "active" });
  await page.goto("/catalog");
  await page.getByRole("heading", { name: "Example Item" }).click();
  await page.getByRole("link", { name: "Buy" }).click();
  // ... complete flow
  await expect(page.getByAltText("Thank you")).toBeVisible();
});

// Unit test - ONLY for pure functions
test("formatCurrency formats with two decimals", () => {
  expect(formatCurrency(1234.5)).toBe("$1,234.50");
});
avoid-component-tests - @rules/avoid-component-tests.md

Don't unit test React components. Test them through E2E or not at all.

// BAD: Component unit test
describe("OrderCard", () => {
  test("renders amount", () => {
    render(<OrderCard amount={100} />);
    expect(screen.getByText("$100")).toBeInTheDocument();
  });
});

// GOOD: E2E test covers the component naturally
test("order history shows orders", async ({ page }) => {
  await page.goto("/orders");
  await expect(page.getByText("$100")).toBeVisible();
});
minimize-mocking - @rules/minimize-mocking.md

Keep mocks simple. If you need 3+ mocks, write an E2E test instead.

// BAD: Too many mocks = write E2E test
vi.mock("~/lib/auth");
vi.mock("~/lib/transactions");
vi.mock("~/hooks/useAccount");

// GOOD: Simple MSW mock for loader test
mockServer.use(
  http.get("/api/user", () => HttpResponse.json({ name: "John" })),
);

E2E Tests (HIGH)

e2e-test-structure - @rules/e2e-test-structure.md

E2E tests go in e2e/tests/, not frontend/.

// e2e/tests/order.spec.ts
import { test, expect } from "@playwright/test";
import { addAccountBalance, createTestingAccount } from "./utils";

test.describe("Orders", () => {
  test.beforeEach(async ({ page, context }) => {
    await createTestingAccount(page, { account_status: "active" });
    let cookies = await context.cookies();
    let account_id = cookies.find((c) => c.name === "account_id").value;
    await addAccountBalance({ account_id, amount: 10000, replaceBalance: true });
  });

  test("place order with default values", async ({ page }) => {
    await page.goto("/catalog");
    // ... user flow
  });
});
e2e-selectors - @rules/e2e-selectors.md

Use accessible selectors: role > label > text > testid.

// GOOD: Role-based (preferred)
await page.getByRole("button", { name: "Submit" }).click();
await page.getByRole("heading", { name: "Dashboard" });

// GOOD: Label-based
await page.getByLabel("Email").fill("test@example.com");

// OK: Test ID when no accessible selector exists
await expect(page.getByTestId("balance")).toHaveText("$1,234");

// BAD: CSS selectors
await page.locator(".btn-primary").click();

Unit Tests (MEDIUM)

unit-test-structure - @rules/unit-test-structure.md

Unit tests for pure functions only. Co-locate with source files.

// app/utils/format.test.ts
import { describe, test, expect } from "vitest";
import { formatCurrency } from "./format";

describe("formatCurrency", () => {
  test("formats positive amounts", () => {
    expect(formatCurrency(1234.5)).toBe("$1,234.50");
  });

  test("handles zero", () => {
    expect(formatCurrency(0)).toBe("$0.00");
  });
});

Key Files

  • e2e/tests/ - E2E tests (Playwright)
  • e2e/tests/utils.ts - E2E test utilities
  • vitest.config.ts - Unit test configuration
  • vitest.setup.ts - Global test setup with MSW
  • app/utils/test-utils.ts - Unit test utilities

Related skills

How it compares

Pick this over generic testing skills when the decision is specifically React component isolation vs E2E user-flow coverage.

FAQ

What is frontend-testing-best-practices?

Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing behavior over implementation details. Use when writing tests or reviewin

When should I use frontend-testing-best-practices?

Testing best practices for the frontend. Emphasizes E2E tests over unit tests, minimal mocking, and testing behavior over implementation details. Use when writing tests or reviewin

Is frontend-testing-best-practices safe to install?

Review the Security Audits panel on this page before production use.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.