frontend-testing-best-practices

Guide frontend testing with E2E tests over unit tests.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/iulspop/misc-skills --skill frontend-testing-best-practices-iulspop
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-testing-best-practices
Source: https://github.com/iulspop/misc-skills/tree/main/.agents/skills/frontend-testing-best-practices
Command: npx skills add https://github.com/iulspop/misc-skills --skill frontend-testing-best-practices-iulspop

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear guidelines and best practices for writing effective, maintainable frontend tests, ensuring higher confidence in application quality and reducing the burden of test maintenance.

Core Features & Use Cases

  • Testing Strategy: Prioritizes End-to-End (E2E) tests over unit tests for most scenarios.
  • Mocking Guidelines: Advises minimizing complex mocking, suggesting E2E tests when extensive mocking is required.
  • Component Testing: Discourages direct unit testing of React components, advocating for their testing within E2E flows.
  • Selector Best Practices: Recommends accessible selectors (role, label, text) over brittle CSS selectors in E2E tests.
  • Use Case: When developing a new feature, consult this Skill to determine the most effective testing strategy (E2E vs. unit) and to ensure tests are robust and maintainable.

Quick Start

Follow the guidelines in this skill to write robust E2E tests for your frontend application.

Frequently Asked Questions about frontend-testing-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to structure frontend tests for maintainability?

The best way to structure frontend tests is prioritizing End-to-End (E2E) flows over unit tests for user behavior, minimizing complex mocking, and using accessible selectors to ensure long-term maintainability and higher confidence in application quality.

Should I unit test React components directly?

You should avoid unit testing React components directly. Instead, test component behavior within E2E flows to ensure robust validation, reserving unit tests primarily for pure functions rather than isolated component rendering.

How do I write robust E2E tests with Playwright?

Write robust E2E tests with Playwright by using accessible selectors like role, label, and text instead of brittle CSS selectors, ensuring tests target user-facing interactions and remain maintainable during UI refactoring.

When should I use E2E tests instead of unit tests?

Use E2E tests instead of unit tests for most user flow scenarios, especially when extensive mocking is required for unit tests. Rely on unit tests only for pure functions to minimize test maintenance burden.

How do I minimize mocking in frontend testing?

To minimize mocking in frontend testing, shift towards E2E tests when unit tests require complex mocks. This strategy reduces mock maintenance and provides higher confidence by validating actual user flows and component interactions.