Skip to the page

React and Next.js · 20 concepts

Testing frontend apps

Decide what to test, write tests that catch real bugs without breaking on refactors, and talk about test strategy like a senior.

Asked in these mock interviews

Part 1 · 3 concepts

What to test and why

  1. 01

    Unit, integration and end-to-end tests; the pyramid vs the trophy

    Unit tests check one small piece in isolation, integration tests check several pieces working together (for frontend: a component with its children, state and a mocked…

  2. 02

    Test coverage: what it means and what it does not

    Coverage reports which lines, branches, functions and statements ran during tests, which shows untested code but not whether the tests check the right things, so use it…

  3. 03

    TDD and writing tests during a coding interview

    Test-driven development is red, green, refactor: write a failing test for the next small behaviour, make it pass simply, then clean up; in interviews, listing test…

Part 2 · 4 concepts

Test runners, assertions and mocks

  1. 04

    Jest vs Vitest in 2026 (and Node's own test runner)

    Jest 30 (June 2025) is still the default for React Native and many older web projects, Vitest (5.1 as of Nov 2026) is the common choice for Vite and modern…

  2. 05

    Test anatomy, assertions and async tests

    A good test arranges data, acts once and asserts the result; toBe compares with Object.is, toEqual compares structure recursively (ignoring undefined properties)…

  3. 06

    Mocks, spies and module mocking

    A mock function records how it was called and returns what you tell it to, a spy wraps a real method, and module mocking replaces an import; mock at the boundaries you…

  4. 07

    Fake timers: testing debounce, throttle, polling and dates

    Fake timers replace setTimeout, setInterval and Date with a clock you move by hand, so you can test debounce, retries, polling and countdowns instantly and…

Part 3 · 5 concepts

Testing React components

  1. 08

    React Testing Library: principles and query priority

    React Testing Library renders components into a DOM and makes you find elements the way users and assistive technology do, so you query by role and accessible name…

  2. 09

    user-event, findBy, waitFor and act warnings

    Simulate users with user-event (await user.click / user.type after userEvent.setup()), wait for UI that appears later with findBy, use waitFor only for assertions that…

  3. 10

    Mocking the network with MSW

    Mock Service Worker intercepts real HTTP requests (with a service worker in the browser and request interceptors in Node), so your components use their real…

  4. 11

    Testing custom hooks

    Test most hooks through a component that uses them, and test a reusable hook directly with renderHook from @testing-library/react, reading result.current, updating…

  5. 12

    Snapshot testing: when it helps and when it hurts

    A snapshot test saves serialised output the first time and fails when it changes, which is cheap protection for small, stable outputs (a formatter, an error message, a…

Part 4 · 4 concepts

End-to-end and component testing

  1. 13

    Playwright essentials: locators, auto-waiting, fixtures, traces

    Playwright drives Chromium, Firefox and WebKit from Node; you find elements with user-facing locators (getByRole), rely on auto-waiting actions and web-first assertions…

  2. 14

    Network mocking, visual comparisons and ARIA snapshots in Playwright

    Playwright can intercept requests with page.route (fulfil, abort or modify them, or replay a HAR), compare screenshots against stored baselines with toHaveScreenshot…

  3. 15

    Cypress vs Playwright

    Cypress runs your test code inside the browser next to the app with a strong interactive runner, while Playwright drives browsers from outside over a protocol, supports…

  4. 16

    Real-browser component tests and contract tests

    Component tests render one component in a real browser (Vitest Browser Mode, Playwright or Cypress component testing, Storybook interaction tests) to check real layout…

Part 5 · 4 concepts

Keeping tests useful

  1. 17

    Automated accessibility testing (axe) and its limits

    Automated tools like axe-core find many common accessibility problems (missing labels, bad ARIA, low contrast) in unit, component and E2E tests, but they cannot judge…

  2. 18

    Flaky tests: causes and real fixes

    A flaky test passes and fails on the same code; the causes are almost always timing, shared state, order dependence, real network or time, or environment differences…

  3. 19

    A CI test strategy that stays fast

    A good CI pipeline runs cheap checks first and on every change (types, lint, unit and integration tests for affected code), a small E2E smoke suite on every PR, and the…

  4. 20

    Testing React Native apps: Jest + RNTL, Detox and Maestro

    React Native apps use Jest with React Native Testing Library for component and integration tests (RNTL 14 makes render and events async and needs React 19 and RN…

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