Skip to content
Goal: Proficient✓ Sources verified 2026-11-25VitestTesting LibraryPlaywrightaxeUsability testingAnalyticsINP

Front-End Testing and Usability Validation ​

You need both kinds of validation: engineering tests prove the UI behaves as designed in every state; usability validation proves users actually understand it and can use it smoothly. The first is automated; the second comes from watching real users and reading real data.

Core concepts ​

TypeWhat it checksTools
Unit testsPure functions, reducers, formatting logicVitest
Component testsRendering and interaction under different props/statesVitest + Testing Library (React / Vue flavors)
E2E testsFull flows in a real browserPlaywright
Automated accessibility checksAutomatically detectable a11y issuesaxe (@axe-core/playwright, Storybook a11y addon)
Visual regressionUnintended style changesPlaywright screenshot comparison, Storybook-based services
Performance metricsLoading and interaction responsivenessLighthouse, the web-vitals library, Chrome DevTools
Usability testingWhether real users can complete tasksTask-based tests, observation, interviews
Product dataReal usage after launchAnalytics events, funnels, retention

How it works ​

1. Test the UI the way users use it ​

Testing Library's guiding principle: the more your tests resemble the way your software is used, the more confidence they can give you. So query by role and accessible name first (getByRole('button', { name: 'Retry from this step' })) rather than by class or test id. This checks accessibility as a side effect: if a button has no name, the test can't find it.

2. Cover every state with "scenario scripts" ​

Timing is the hardest part of testing live UIs. Record or write back-end event streams as scripts (JSON arrays) and replay them in tests:

ScriptStates covered
happy-pathqueued → running → succeeded
retry-then-successretrying 2/3 → succeeded
partial-failurepartially_succeeded with 3 failed items
needs-humanwaiting_human → user submits → running
disconnectconnection drops → reconnecting → recovered after replay

Unit-test the reducer event by event; component and E2E tests use the same scripts, so "every state in the design has a test".

3. Why 5 users are worth testing ​

Jakob Nielsen's classic finding: qualitative testing with 5 users finds most usability problems, and it's better to run several small rounds, fixing issues between them. NN/g also stresses that this applies to qualitative testing; statistically reliable quantitative metrics need larger samples (their article suggests around 40 participants or more).

4. Rating severity ​

Following NN/g's approach to severity ratings, combine frequency, impact and persistence:

LevelMeaningAction
4 CatastropheUsers can't complete the taskMust fix before release
3 MajorSeriously slows users down or causes errorsHigh priority
2 MinorAnnoying but completableSchedule a fix
1 CosmeticDoesn't affect completionFix when there's time

In practice ​

Reducer unit tests (Vitest) ​

ts
import { describe, it, expect } from 'vitest'
import { reduce, initial } from './taskReducer'
import needsHuman from './scenarios/needs-human.json'

describe('taskReducer', () => {
  it('enters the waiting-for-human state', () => {
    const state = needsHuman.slice(0, 4).reduce(reduce, initial)
    expect(state.status).toBe('waiting_human')
  })
  it('does not double-count duplicate events', () => {
    const e = needsHuman[1]
    const once = reduce(initial, e)
    expect(reduce(once, e)).toEqual(once)
  })
})

E2E + accessibility check (Playwright) ​

ts
import { test, expect } from '@playwright/test'
import AxeBuilder from '@axe-core/playwright'

test('a human request can be handled and the task continues', async ({ page }) => {
  await page.goto('/tasks/demo?scenario=needs-human')
  await expect(page.getByRole('status')).toContainText('Needs you')
  await page.getByRole('button', { name: 'Handle it' }).click()
  await page.getByRole('textbox', { name: 'Search keywords' }).fill('agent evaluation')
  await page.getByRole('button', { name: 'Submit and continue' }).click()
  await expect(page.getByText('Task continuing')).toBeVisible()

  const results = await new AxeBuilder({ page }).analyze()
  expect(results.violations).toEqual([])
})

Running a usability test ​

StepWhat to do
1. GoalE.g. can users find out why a task failed and get it going again?
2. TasksDescribe a scenario without using UI wording: "Your research task seems to have stopped. Find out what happened and get it to finish."
3. Participants5 people close to the target users; remote is fine
4. ObserveAsk them to think aloud; observe without guiding; record success/failure, time and where they got stuck
5. SummarizeIssue list + severity + how many people hit it + screenshots/clips
6. IterateFix the most severe issues, then rerun the same tasks next round and compare

Optional: after the test, use the SUS (System Usability Scale, a 10-question survey) for a comparable satisfaction score.

Validating with data after launch ​

QuestionEvent / metric
Do users handle human requests in time?Distribution of time from request to response
Are error cards useful?Share of "retry / edit / give up" clicks after failures; abandonment after failure
Is the timeline used?Detail expansion rate, "jump to failure" clicks
Does the UI feel fast?INP (Interaction to Next Paint, "good" at ≤ 200ms), reported with the web-vitals library

Name events consistently (object_action, e.g. human_request_submitted) and attach context such as task status; collect only what's needed and never the text users type.

Common pitfalls ​

  1. Tests written against classes or DOM structure: break on every style change and miss accessibility problems.
  2. Only the happy path is tested: errors, partial success and disconnects, the states that most need tests, go untested.
  3. E2E depends on a real LLM: slow, costly and nondeterministic. Replay scripts or mock (e.g. MSW).
  4. Guiding users during usability tests: "You can click the button at the top right" makes the result meaningless.
  5. Percentages from a 5-person test: qualitative tests find problems; they can't support "80% of users are satisfied".
  6. Lots of events nobody looks at: every event should answer a specific question.

Common interview questions ​

  1. How would you design tests for a live-updating status UI?
  2. Why does Testing Library recommend querying by role?
  3. How do E2E tests avoid depending on a real back end and LLM?
  4. Why are 5 users enough for a usability test? When aren't they?
  5. How do you judge the severity of a usability problem?
  6. After launch, which data shows that "users understand task status"?
  7. What is INP, and what is the "good" threshold?
  • Agent Run Console: the 5 scenario scripts drive the demo, Vitest and Playwright alike; D18–21 runs a 5-person usability test and one iteration, written up on the case study page.
  • This site: run Lighthouse and axe once to set a baseline for accessibility and performance.

Sources ​

Vin Amory · AI development × content creation · Technical notes cite official docs in each page’s sources section