Write end-to-end (E2E) tests around a few important things a user must be able to do—not around every page or button. A browser-driven test can follow a workflow from the interface through your backend and integrations, so it can catch failures that isolated component or API tests cannot. Keep the suite focused, make each test independent, and assert visible outcomes with locators and assertions that wait for the browser state.
Choose workflows worth testing end to end
An E2E test drives your app through a browser and can exercise the backend and third-party integrations along the way. That makes it useful for checking complete user outcomes, but it also brings more setup and maintenance than narrower tests. Cypress describes E2E testing as testing from the browser through the backend, including integrations with third-party APIs and services (Cypress testing types).
As an Amazon Associate I earn from qualifying purchases.
Start with workflows that would materially undermine release confidence if they broke. Examples include:
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 minute- A user signs in and reaches the expected account screen.
- A customer completes a purchase and sees the resulting confirmation.
- Information entered on one screen is still present on another.
- A key release smoke-check path works against the deployed or test environment.
Do not make E2E the only kind of test. Use browser tests for cohesive user journeys, and use component, API, or accessibility-specific tests when those are a better fit for the behavior you need to verify. Cypress notes that its testing types have different strengths and that E2E tests require more infrastructure and maintenance (Cypress testing types).
Prepare a predictable app and test environment
A browser test is only useful when its starting conditions are known. Decide how the test app will run, where its backend dependencies live, and how test data is created or reset. Keep credentials and other secrets in your test environment rather than hard-coding them into test files.
- Use a test environment with controlled data and dependencies.
- Create the records a test needs, or reset relevant state before it runs.
- Make sure tests do not depend on running in a particular order.
- For logged-in tests, choose deliberately between exercising the UI login flow and establishing authentication programmatically. Cypress recommends programmatic login when repeating the UI sequence is not itself what the test needs to verify.
Start the app server as part of the test environment setup rather than trying to launch it inside test scripts; Cypress documents that approach in its Testing Your App guide.
Write a Playwright test from outcome to assertion
This example checks a sign-in workflow: open the sign-in page, enter credentials, submit the form, and verify a user-visible result. Replace the URL, labels, and expected text with those used by your app. It assumes the test environment provides the credentials in environment variables.
Free tools Windows power users keep installed
One-click scans. No signup required.
import { test, expect } from '@playwright/test';
test('user can sign in', async ({ page }) => {
const email = process.env.TEST_USER_EMAIL;
const password = process.env.TEST_USER_PASSWORD;
if (!email || !password) {
throw new Error('Set TEST_USER_EMAIL and TEST_USER_PASSWORD');
}
await page.goto('http://localhost:3000/sign-in');
await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Sign in' }).click();
await expect(page.getByRole('heading', { name: 'Your account' }))
.toBeVisible();
});
The final assertion checks what the user can observe rather than an internal state variable or a particular DOM arrangement. Use an outcome that demonstrates the workflow actually succeeded: for example, a confirmation message or the expected persisted value, not merely that a submit button was clicked.
Choose locators that survive interface changes
Prefer selectors based on how a user identifies an element. In Playwright, that usually means a role and accessible name for controls, a label for form fields, or visible text when the text is the relevant user-facing signal. A test ID is reasonable when you need an explicit test contract and user-facing attributes do not identify the target uniquely. See the Playwright locators guide.
- Good default:
getByRole('button', { name: 'Save' }). - For a labeled field:
getByLabel('Email'). - When needed as a deliberate contract:
getByTestId('save-profile'). - Usually brittle: long CSS or XPath chains that encode the current nesting or styling classes.
Playwright’s guidance is to verify behavior as end users experience it and avoid dependencies on implementation details (Playwright best practices). A role-based locator alone does not prove a feature is accessible or fully tested; it is a locator strategy, not a complete accessibility audit.
Wait for browser conditions, not guessed delays
Browser actions and page updates are asynchronous. Playwright checks whether an action is actionable before performing it, and its async assertions retry until their condition is met. Use those mechanisms to wait for a meaningful state:
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByText('Changes saved')).toBeVisible();
A fixed delay such as page.waitForTimeout(2000) does not establish that the expected outcome occurred. It can waste time when the page responds quickly and still fail when it responds more slowly. Prefer a condition such as a confirmation becoming visible, a specific URL being reached, or expected data appearing. Playwright documents its actionability checks and retrying assertions in Writing tests.
Keep tests independent and state under control
Each test should be runnable by itself. Set up the data and authentication it needs, and avoid relying on a previous test to create a user, leave a session active, or navigate to a particular screen. Isolate cookies and storage so one test cannot accidentally pass or fail because another changed browser state. Playwright and Cypress both recommend controlling test state and avoiding order-dependent tests (Playwright best practices; Cypress best practices).
Rank #4
There is one important qualification: setup should match what the test is intended to prove. If the workflow under test is signing in, exercise the sign-in UI. If the test is about a different authenticated workflow, programmatic authentication can avoid repeating an unrelated login journey in every test.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Run the suite in CI and diagnose failures
Run important E2E checks regularly in continuous integration. Playwright recommends running tests ideally on each commit and pull request, and notes Linux as a lower-cost CI environment without specifying a savings amount (Playwright best practices). Make the app server, test data, secrets, and backend dependencies part of the CI setup so runs start from a repeatable environment.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →When a check fails, identify which part of the workflow did not reach its expected condition. Confirm that the app and dependencies were available, the required data and credentials existed, and the locator still matches the intended user-facing control. Avoid making a failure disappear by adding a longer sleep unless the test is actually meant to wait for a defined delay.
Best Value
Playwright or Cypress?
Both are options for browser-based E2E testing; the official material cited here does not establish a universal winner. Compare the browser coverage you need, language and ecosystem fit, local debugging workflow, CI operation, and how your team will control application state. Playwright’s cited documentation covers locators, retrying assertions, and CI guidance; Cypress’s documentation discusses E2E alongside other testing types and its setup and maintenance demands. Choose against your project’s requirements rather than an unsupported speed or reliability ranking.
Common mistakes to avoid
- Testing every small interaction end to end instead of prioritizing consequential workflows.
- Using fragile styling classes or long selector chains that break when markup changes.
- Checking immediately before the page reaches the expected state, or masking timing uncertainty with arbitrary sleeps.
- Sharing state between tests or assuming a specific execution order.
- Covering only the happy path while ignoring authentication, persistence, or transaction outcomes that matter to users.
- Treating E2E checks as a replacement for component, API, or accessibility testing.
Or skip the browser setup
If you need a screenshot of a page for a visual check or a workflow that does not require interactive browser assertions, ScreenshotNeo can return a screenshot or PDF from one GET request. This does not replace an E2E test that must interact with controls and verify application behavior.
cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots, and 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000. Sign up for free ScreenshotNeo screenshots.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Frequently Asked Questions
Can an E2E test prove that a website is accessible?
No. A browser workflow can use accessible roles and labels, but that alone does not provide complete accessibility coverage.
Should every test repeat the sign-in flow?
Only when signing in is part of the behavior that test is meant to verify; other authenticated tests can establish login state separately.
Quick Recap
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.




