Start with the behavior you need confidence in, then test it at the lowest level that exercises it meaningfully: isolated logic with unit tests, component and service interactions with integration tests, and a small set of critical user journeys in a real browser. The testing pyramid is a guide to balancing speed, diagnostic value, and confidence—not a required ratio of test counts.
What the testing pyramid means for a frontend
The pyramid represents a practical trade-off. Focused tests near the bottom are generally easier to run and diagnose; tests near the top exercise more of the application in a realistic environment but require more setup and can be more expensive to maintain. The UK Home Office describes the approach as broad lower layers and fewer end-to-end tests, while noting that the balance should reflect the system’s complexity, risk, time, and resources (Home Office test pyramid guidance, updated 31 October 2025).
As an Amazon Associate I earn from qualifying purchases.
For frontend work, think in terms of the behavior under test rather than a fixed layer name. A price calculation can often be checked as isolated logic. Whether a form displays validation and responds to a user’s input is a component behavior. Whether submitting that form persists data through an API may need integration coverage. Whether a customer can sign in and complete a purchase is a user journey worth checking end to end.
Choose the narrowest test that gives useful confidence. Add broader coverage when a risk depends on the interaction of multiple parts or on the application running as a user experiences it.
Where to start: a practical sequence
- Identify user-impacting risks. List the behaviors whose failure would materially harm users: for example, navigation, sign-in, a key form submission, or purchasing. Cypress cites authentication, purchasing, and multi-screen data persistence as common end-to-end scenarios (Cypress testing types).
- Cover isolated logic with unit tests. Test calculations, transformations, validation rules, and other deterministic logic directly when doing so gives quick, clear feedback. A failing focused test should help you locate the defect without having to infer it from a long browser flow.
- Test components through rendered behavior. Exercise important states and interactions as they appear to a user: what is displayed, what changes after an action, and what feedback is given. If the behavior depends on browser rendering, a browser-based component test can mount the component directly; Cypress documents component testing as a distinct test type.
- Add integration tests at meaningful seams. Cover behavior that depends on two or more parts working together, such as a component and its API boundary or several components sharing state. Keep the setup as narrow as possible while still exercising the interaction that could fail.
- Use end-to-end tests for critical journeys. Verify a short list of important flows in the running application, such as sign-in or purchase completion. A browser test is most useful when the risk is in the complete path rather than one isolated piece.
- Review the value of each test. Keep tests that provide useful confidence and actionable failures. Rework or remove checks whose maintenance, flakiness, or execution cost outweighs what they tell you.
What belongs at each layer
Unit tests: isolated rules and transformations
Use unit tests when the behavior can be tested without rendering the application or crossing an external boundary. Typical candidates include formatting, calculations, branching rules, and data transformations. They are especially useful when a failure should point to one small piece of logic. They cannot, by themselves, establish that a user can complete a whole task.
Component tests: visible states and interactions
Component tests focus on a UI unit and its behavior: whether the right content is shown, whether an action changes the interface, and whether important states are handled. Cypress describes component testing as mounting components directly in a browser (Cypress testing types). The choice of browser or other test environment should follow the behavior you need to exercise.
Integration tests: interactions across boundaries
Use integration tests where correctness depends on parts meeting: a form calling an API, components coordinating, or state flowing through a broader slice of the application. An integration test need not reproduce an entire customer journey. Prefer the smallest arrangement that covers the seam at risk, so failures remain understandable.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteEnd-to-end tests: a few complete user journeys
End-to-end tests exercise the application through a real user-facing flow. They can catch failures that isolated checks miss, including broken wiring between screens or services. Cypress notes that they also involve more setup, infrastructure, execution, and maintenance work than focused checks (Cypress testing types). Reserve them for flows whose full completion matters, rather than using them as the default way to test every small rule or UI state.
API and accessibility tests: choose by the risk
Test an API directly when the behavior of the interface depends on a service contract or response. Accessibility checks address a different quality concern: whether users can perceive and operate the interface. Cypress documents API and accessibility testing alongside end-to-end and component testing; these are test types to choose according to the application and question, not extra mandatory pyramid layers (Cypress testing types).
Test what users can see and do
Tests should usually interact with the rendered interface rather than depend on internal implementation details that users cannot observe. Playwright’s best-practice guidance puts it this way: “The end user will see or interact with what is rendered on the page, so your test should typically only see/interact with the same rendered output” (Playwright Best Practices).
Rank #4
That does not mean every test must use a browser. It means the test should represent the behavior at the level where confidence is needed. Test an internal calculation directly if that is the risk; test rendered output when presentation and interaction matter; use a full browser journey when the complete path is the thing at risk.
Recommended Free Tools
How many tests should be at each level?
There is no universal frontend ratio. The Home Office guidance explicitly warns that the pyramid is not a perfect fit for every situation and recommends adapting it to factors such as complexity, rapid prototyping, safety needs, and resources (Home Office test pyramid guidance).
Best Value
Google Testing Blog offered a historical starting suggestion in “Just Say No to More End-to-End Tests,” published in April 2015: “As a good first guess, Google often suggests a 70/20/10 split: 70% unit tests, 20% integration tests, and 10% end-to-end tests” (Google Testing Blog). Treat that as a heuristic from that 2015 article, not a measured universal benchmark or a current official policy for every frontend team.
Adjust the mix to risk and feedback. A complex integration or AI-driven system may justify more end-to-end coverage, while a short-lived application may make user testing more appropriate; these are contextual examples in the Home Office guidance, not rules for all projects. GitLab also publishes organization-specific testing-level guidance and data, which should not be mistaken for a general prescription (GitLab testing levels).
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Choose tests by the trade-off they address
| Question | What to consider |
|---|---|
| Does it reflect user-visible behavior? | Rendered component checks and browser journeys can reflect what users see and do; isolated logic tests answer narrower questions. |
| Will a failure be easy to diagnose? | Focused tests usually point more directly to a failing rule or seam. A whole journey can show that a flow broke without immediately identifying where. |
| How quickly is feedback needed? | Consider how often the check runs and whether its execution time delays useful feedback. |
| What setup does it require? | Account for browser, service, test-data, and infrastructure needs, especially for full-flow checks. |
| How much maintenance or flakiness is acceptable? | Assess whether the test remains reliable as the interface and dependencies change, and whether failures are actionable. |
| Which boundary could fail? | Choose a test that actually crosses the component, API, or service seam implicated by the risk. |
These questions are a decision aid, not a universal scoring system. Cypress documents multiple testing types and recommends choosing in light of the application and the test need; it does not make one type the right answer for every frontend (Cypress testing types).
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Use screenshots as a visual check, not a substitute for behavior tests
A screenshot can help compare a rendered page or document visually, but it does not prove that a form submits, an API works, or a complete user journey succeeds. Keep visual output checks tied to the behavior they are intended to protect.
Or skip the browser setup
For a screenshot of a URL, ScreenshotNeo provides a one-request option; it is not a replacement for the unit, component, integration, or end-to-end tests described above. See the ScreenshotNeo documentation.
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan. Learn more at ScreenshotNeo, or sign up for free.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




