sergiodxa avatar

Frontend Testing Best Practices

Testing guidelines that favor E2E tests over unit tests, limit mocking, and check behavior over implementation.

skills.sh installs
2.3K
GitHub stars
92
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers test strategy, E2E structure, selector choice, and unit test layout for frontend code
  • Includes 6 rules with code examples, including a prefer-e2e-tests rule and an avoid-component-tests rule
  • Enforces a mock limit where 3 or more mocks signal that an E2E test should replace the unit test
  • Guides selector choice in order: role, label, text, then test ID, with CSS selectors marked as bad
  • Designed for frontend teams writing or reviewing Playwright and Vitest tests

Install

$ npx -y skills add sergiodxa/agent-skills --skill frontend-testing-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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.

Details

Repository
github.com/sergiodxa/agent-skills
Categories
Testing & QA, Frontend & UI Code

More from sergiodxa/agent-skills

All 10

Similar to Frontend Testing Best Practices

More Testing & QA