What Is UI Testing? How It Differs From End-to-End Testing
UI testing checks one screen's controls, states and errors with the backend stubbed. See a sign-up screen tested two ways in Playwright, and what each catches.
UI testing checks that one screen of an app behaves as it should (its controls, states, error messages and input rules), usually with the rest of the stack held still so only the screen can fail.
The trouble is the word. A UI test and an end-to-end test click through the same screens with the same tools, and they often share a folder. They answer different questions. One sign-up screen, tested both ways in Playwright and broken twice, shows which test each bug belongs to.
What you’ll learn
- What a UI test checks, and the line that separates it from an end-to-end test
- Three stubbed UI tests and one end-to-end test for a sign-up screen, in Playwright code we ran
- Two deliberate breaks, and which level caught each one
- Which bugs are the cheaper catch at each level, and the tools for web, Android and iOS
What Is UI Testing?
UI testing is the practice of checking an application’s interface the way a user meets it. You open a screen, interact with it, and assert on what it shows. A UI test asks whether that one screen behaves. Does the button lock while a request is in flight? Does the error appear under the field it’s about? Does the screen keep what the user typed when the server fails?
The term gets used loosely. Android’s testing guide says UI tests “launch an app (or part of it), then simulate user interactions, and finally check that the app reacted appropriately,” and that they range “from verifying the behavior of a small component to a large navigation test that traverses a whole user flow.” With a range that wide, the tool can’t be the line. What the test fakes can.
The same guide suggests replacing the data layer with an in-memory fake that provides “fake, deterministic data to the test,” swapped in through dependency injection. In the narrow sense, a UI test does exactly that. The screen is real, and everything behind it answers on cue. It works from outside the code, the way black box testing does, but it also reaches behind the screen to decide what the screen hears back.
A UI test asks whether one screen behaves with everything behind it held still. An end-to-end test asks whether a journey works across the whole stack.
Two other kinds of check also go by the name. Whether a screen looks right across sizes and releases is the job of visual regression testing, which compares screenshots with a baseline. Whether people using screen readers or keyboards can use it is the job of accessibility testing.
UI Testing vs End-to-End Testing
Both kinds drive a real screen with the same tools, so the difference sits in what’s real behind the screen and what a failure tells you. End-to-end testing runs a journey through every layer, the UI, API, database and anything else the journey touches, such as email, and fails when any of them breaks the journey. A UI test stubs the server and its data, so when it fails, the screen is the suspect.
| Dimension | UI test | End-to-end test |
|---|---|---|
| Question it answers | Does this screen behave? | Does this journey work? |
| What’s real | The screen, in a browser or on a device | The UI, API, database and anything else the journey touches |
| What’s stubbed | The API and data behind the screen | Nothing, or only services you don’t own |
| States it can reach | Any, on demand: slow, failing or conflicting responses | The ones the real system produces |
| A failure points at | The screen’s code | Anywhere along the journey |
| How many you want | One per state a user can see | One per journey you can’t afford to break |
Write the state checks as UI tests, and save end-to-end tests for the journeys your business can’t lose.
A Sign-Up Screen, Tested at Both Levels
The screen is a sign-up form with an Email field, a Password field and a Sign up button. A small Node server behind it creates the account and writes a verification email to an outbox. A test-only endpoint returns the last message written for an address, so a test can read it. We ran both specs below with Playwright 1.65.1 on Chromium and Node 22.21.0.
The UI tests stub the sign-up API with page.route. With a route fulfilled this way, as Playwright’s docs on mocking APIs put it, “No requests to the API will be made.” Each test picks the server’s answer: a taken email, a slow response, a failure.
// signup-ui.spec.ts: the sign-up screen alone, with the API stubbed
import { test, expect } from '@playwright/test';
test.beforeEach(async ({ page }) => {
await page.goto('/signup');
await page.getByLabel('Email').fill('[email protected]');
await page.getByLabel('Password').fill('correct-horse-1');
});
test('taken email: error under the field, button usable again', async ({ page }) => {
await page.route('**/api/signup', (route) => route.fulfill({ status: 409, body: '{"error":"email_taken"}' }));
await page.getByRole('button', { name: 'Sign up' }).click();
await expect(page.locator('#email-error')).toHaveText('This email already has an account. Sign in instead?');
await expect(page.getByRole('button', { name: 'Sign up' })).toBeEnabled();
});
test('slow server: button locked while the request is in flight', async ({ page }) => {
let release!: () => void;
const held = new Promise<void>((resolve) => (release = resolve));
await page.route('**/api/signup', async (route) => { await held; await route.fulfill({ status: 201, body: '{}' }); });
await page.getByRole('button', { name: 'Sign up' }).click();
await expect(page.getByRole('button', { name: 'Signing up...' })).toBeDisabled();
release();
await expect(page.getByRole('heading', { name: 'Confirm your address' })).toBeVisible();
});
test('server error: message shown, typed email kept', async ({ page }) => {
await page.route('**/api/signup', (route) => route.fulfill({ status: 500 }));
await page.getByRole('button', { name: 'Sign up' }).click();
await expect(page.locator('#form-error')).toHaveText('Something went wrong. Try again.');
await expect(page.getByLabel('Email')).toHaveValue('[email protected]');
});
Two of those three states show up against a real backend only on a bad day. Making a server slow or failing on purpose takes setup, while a stub does it in one line.
The end-to-end test stubs nothing. It signs up a fresh address and reads the verification message through the test-only endpoint. Then it opens the link and checks that the account is verified.
// signup-e2e.spec.ts: the real server and the link it wrote, nothing stubbed
import { test, expect } from '@playwright/test';
test('new user signs up and verifies their email', async ({ page, request }) => {
const email = `new-${Date.now()}@example.com`;
await page.goto('/signup');
await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill('correct-horse-1');
await page.getByRole('button', { name: 'Sign up' }).click();
await expect(page.getByRole('heading', { name: 'Confirm your address' })).toBeVisible();
const { body } = await (await request.get(`/test/outbox?to=${encodeURIComponent(email)}`)).json();
const link = body.match(/https?:\/\/\S+/)[0];
await page.goto(link);
await expect(page.getByRole('heading', { name: 'Email verified' })).toBeVisible();
});
All four passed on the clean build. Then we broke the app twice, once behind the screen and once on it, and ran the same four tests against each break.
| Break | UI tests (3) | End-to-end test (1) |
|---|---|---|
The server’s verification link points at /verfy instead of /verify | 3 passed | Failed, no “Email verified” heading |
| The screen never unlocks the button after a failed request | 2 passed, the taken-email test failed | Passed |
Each break failed exactly one level. The link typo lives behind the screen, where no stub can see it. The locked button only appears after a failed request, and the happy-path journey never makes one. A user whose email was already taken would have been stuck on a button reading Signing up… with nothing to press. A suite with only one of the two levels ships one of these bugs.
Which Bugs Each Test Catches Cheaper
Cheaper means less time to write, run and diagnose. UI tests need no test data, no inbox and no deployed backend. An end-to-end test costs more every time it runs, and it’s the only one of the two that proves the parts agree.
| Bug | Cheaper catch | Why |
|---|---|---|
| Error shown under the wrong field, or with the wrong text | UI test | Stub the error response once and assert on the screen |
| Button stays locked after a failed request | UI test | A real server rarely fails on cue |
| Double submit while the request is slow | UI test | A held route makes “slow” happen every run |
| Typed input lost after a server error | UI test | A stubbed 500 costs one line |
| No message when an invalid email loses focus | UI test | No request involved, only the screen’s input rule |
| Verification link points at the wrong path | End-to-end test | Only the real email carries the real link |
| Account created, but the session never starts | End-to-end test | Needs the real API and the real cookie |
| Screen and API disagree on a field name | End-to-end test | A stub encodes your assumption about the API, so it agrees with your bug |
End-to-end tests earn their cost on journeys. Spend one on a state and you pay for a full stack to learn that a button didn’t unlock. Stubbing also takes network timing out of the state checks, and timing is one common source of flaky tests. The journeys carry the integration risk instead.
Which Tools Run Automated UI Tests?
Most test automation tools can run both levels. The split lives in how you write the test, mostly in whether you stub the server the screen talks to.
| Platform | Common tools | How the backend gets stubbed |
|---|---|---|
| Web | Playwright, Cypress, Selenium | page.route in Playwright, cy.intercept in Cypress, request and response handlers through WebDriver BiDi in Selenium |
| Web components | Testing Library, Playwright and Cypress component testing | The component renders alone, with props instead of a backend |
| Android | Espresso, Compose testing APIs | A fake data layer injected through dependency injection |
| iOS | XCUITest | A fake backend wired into the app’s own test setup |
Both Playwright and Cypress stub the network well, so the Playwright vs Cypress choice turns on other things, such as the languages your team writes and how you run tests in parallel. When one screen’s checks shrink to a single widget, a component test is the smaller tool for the job.
On iOS, XCUITest drives the app from outside its code, so any fake backend has to be wired into the app’s own test setup. On phones the split holds, and mobile app automated testing adds devices and OS versions to every decision.
When the markup changes, UI tests break on how they find elements. Self-healing test automation handles that in one of two ways. Some tools swap a broken locator for its likeliest match. Other AI testing tools, Pie among them, look for each element on the screen first.
Pie’s Self-Healing Tests Read the Screen
The specs above find most elements by label and role, which survives more change than a CSS selector. The two error checks lean on element ids. Both break the moment somebody rewords a label or renames an id. The end-to-end spec crosses the most screens, so it has the most labels to break.
We built Pie to test from the screen. Our agentic testing platform runs the journeys on your app with nothing stubbed. Your stubbed state tests stay in your repo, next to the screen’s code.
- iOS and Android apps: Pie’s tests are vision-only. They find the Sign up button on the screen as rendered, with no locator behind it.
- Web apps: Pie’s tests are vision-first, starting from the page as a user sees it.
- On every run: Pie’s self-healing tests re-read the screen each time they run, so they’re built to survive redesigns. Your team doesn’t write or maintain selectors for Pie’s tests.

Test the Screen, Then the Journey
The sign-up screen needed both tests, and the two breaks proved it, since each test caught only its own break. Open the screen your users hit first and list the states a user can see on it: empty, invalid, waiting, failed, taken and done. Write a stubbed UI test for each, then keep one end-to-end test that walks the journey through the real stack.
The journeys cost the most to run and keep current. Hand those to Pie, which re-reads the screen on every run.
Keep the State Tests, Add the Journeys
Name the journeys you can't lose. Pie runs them in web, iOS and Android apps.