Skip to the page

Testing a UI feature and estimating · mid

Testing search, lists, forms and offline sync

Each UI pattern has its own risks: timers and races in search, duplicates in lists, error states in forms, and queues in offline sync. Test the behaviour the user sees, with fake timers, network mocks and real devices where needed.

The notes

What you must know

  • Autocomplete behaviours: debounce (no call per keystroke), minimum length, loading, empty and error states, highlight, keyboard and mouse selection, Escape, click outside, clear button. Use fake timers with user-event advanceTimers.
  • Race: with MSW make the first request slow and the second fast, then assert the list matches the last query (fix with AbortController or a latest-request-wins check). Accessibility: the combobox pattern and axe checks.
  • Infinite list: first page, next page at the end, end of list, error and retry, empty, no second fetch while one runs, duplicates across pages (offset paging while items are added; cursor paging fixes it), back navigation keeps position. Mock IntersectionObserver by hand; run one end-to-end scroll test in Playwright.
  • Virtualisation: test that the number of DOM nodes stays bounded. React Native FlatList onEndReached can fire more than once, so test the guard.
  • Form validation: put rules in a schema (zod, valibot or yup) shared with or generated from the server contract and test it with tables of valid and invalid values. Pick cases by equivalence classes and boundaries (age exactly 18, PAN pattern ABCDE1234F, 6-digit PIN).
  • UI tests for forms: errors on blur and on submit, conditional fields, submit button state, focus to the first error, server 422 errors mapped to fields, aria-invalid and aria-describedby. The server remains the source of truth.
  • Offline sync cases: create offline and sync later; airplane mode mid-request; app killed; storage full; an app update with items queued; wrong phone clock; expired login on return. Simulate with mocked NetInfo, a proxy that drops requests, or Maestro or Detox flows.
  • No duplicates: a client-made UUID per order used as idempotency key; test by sending twice and by losing the response. Keep the outbox in durable storage (SQLite) with a status per item and backoff. Agree a conflict rule (last write wins, merge by field, ask the user).

The red pen

Common traps: mistake → fix

  • Mistake: Mock the component own fetch function

    Fix: mock the network (MSW) so the real code runs.

  • Mistake: Offset paging is fine while data changes

    Fix: items shift and duplicate; use a cursor.

  • Mistake: Testing the happy path of a form is enough

    Fix: boundaries, server errors and focus matter.

Easy to hard

Questions interviewers ask, easy to hard

  1. How would you test an autocomplete search box?
  2. How do you test an infinite scrolling list?
  3. How do you test a form with complex validation?
  4. How do you test offline sync in a mobile app?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview