Component Testing SDET Interview Questions 2026 — The Playwright Component Testing, Cypress Component Testing, Testing Library, and Isolation vs Integration Questions Senior Panels Ask That Expose Candidates Who've Only Written End-to-End Tests
Real component testing SDET interview questions from senior panels in 2026. Covers Playwright Component Testing, Cypress Component Testing, Testing Library philosophy, mount vs render, mocking strategies, accessibility assertions, visual regression at component level, and when to use component tests vs end-to-end tests. Built from Mitchell Agoma's 20-year experience across HMRC, MoD, Nationwide, Accenture, Asda, Co-op, and BT.
Published 29 June 2026 • By Mitchell Agoma
It is 11:14pm. Your senior SDET interview is at 9am — the one where the hiring manager said "the team is modernising their frontend testing strategy" and the job spec said "experience with component-level testing in Playwright or Cypress." You have written hundreds of end-to-end tests. You can navigate a checkout flow, verify API responses, and debug a flaky Selenium test at 2am. You have celebrated the green pipeline and cursed the red one. But when you close your laptop, one phrase keeps looping in your mind like a stuck record: component testing. It appeared in the job description — "must be comfortable mounting components in isolation using Playwright Component Testing or Cypress Component Testing" — and you felt a cold flutter of recognition. You have never mounted a React component in isolation. You have never used mount(). You have never written a test that renders a single button and asserts its label without navigating through a login page, a dashboard, and three intermediate screens. And when the interviewer asks you the question that separates candidates who test from candidates who engineer — "Walk me through how you would test this dropdown component in isolation — including its open/close behaviour, keyboard navigation, ARIA attributes, and loading state" — you realise the answer is not "I would write an end-to-end test that opens the page containing the dropdown." The answer is a component test. And the follow-up that makes your mouth go dry: "Now tell me when you would choose a component test over an end-to-end test — and what you lose with each approach."
Here is the uncomfortable truth: the component testing question is where candidates who have written ten thousand end-to-end tests still lose offers. Because component testing exposes a different kind of signal — whether you understand that the fastest, most reliable, and most debuggable test is the one that runs closest to the code it tests. Most SDET candidates have written end-to-end tests that take 8 minutes to run and fail for reasons unrelated to the code change. Almost none have mounted a component in isolation, mocked its dependencies, asserted its accessibility tree, and run the whole suite in 4 seconds. The panel knows this. When they ask about component testing, they are filtering for the minority who have moved beyond "open the browser and click through the app" into the discipline of component-level verification.
Mitchell has watched this exact gap cost candidates offers across two decades — at Ascda, where the e-commerce platform's frontend had 40+ React components (product card, price display, basket icon, quantity selector, promo banner, search autocomplete, filter sidebar, sort dropdown, pagination, review stars, size selector, colour swatch, delivery estimate, stock indicator, add-to-basket button, wishlist heart, recently-viewed carousel, breadcrumb, header navigation, footer links, cookie banner, newsletter signup, store locator map, checkout stepper, payment form, address lookup, order summary, confirmation page, error boundary, loading spinner, skeleton loader, modal dialog, tooltip, toast notification, accordion FAQ, tab panel, carousel, image gallery, and zoom overlay) and the team that wrote component tests for the payment form caught 23 bugs before a single end-to-end test ran — including a regression where the expiry-date field accepted past dates, a race condition where the "pay" button enabled before the CVV field was validated, and a keyboard-trap in the card-number field that blocked VoiceOver users — while the team that relied solely on end-to-end tests discovered these bugs in staging, three days later; at the Co-op, where the membership app's frontend had 25 components and the component test suite for the offers carousel (which displayed personalised discounts based on membership tier, purchase history, and store location) found that the carousel rendered an empty state when a member had exactly one eligible offer (an off-by-one error in the pagination logic that e2e tests never hit because test accounts always had multiple offers) — and the component test caught it in 1.2 seconds, in the developer's local environment, before the PR was even opened; at BT, where the broadband-configurator frontend had 30 components and the component test suite for the postcode-lookup component (which called an address-validation API, displayed results in a dropdown, and fed the selected address into a broadband-availability check) found that the component's loading state rendered an unstyled text node when the API returned exactly one address — a visual regression that e2e tests missed because the screenshot threshold was too permissive, but a component-level visual regression test caught with pixel-perfect precision; at Nationwide, where the mortgage-application frontend had 35 components and the component test suite for the affordability-calculator component (which took income, outgoings, deposit, and term as inputs, called an affordability-check API, and displayed max loan, monthly payment, and LTV ratio) found that the calculator displayed NaN for monthly payment when the user entered a term of 0 years — an edge case that e2e tests never covered because the happy-path test data always used a 25-year term. The component test — which passed {term: 0} as a prop in a 3-line test — caught the NaN before a single user typed 0 into the term field; at HMRC, where the tax-return frontend had 22 components and the component test suite for the income-source selector (a multi-select dropdown with search, group headers for employment/self-employment/investment/pension/other, and a "select all" toggle) found that selecting "select all" in one group (employment) also selected items in the next group (self-employment) because of a shared-arrays-by-reference bug in the state reducer — a bug that e2e tests never reproduced because test scenarios always selected individual items, never used "select all" across groups; at the Ministry of Defence, where the security-clearance frontend had 18 components and the component test suite for the document-upload component (which accepted PDF, JPG, and PNG files up to 10MB, displayed upload progress, and showed validation errors for wrong file types, oversized files, and corrupted PDFs) found that the component's drag-and-drop handler accepted .exe files when dropped onto the drop zone, even though the file-input accepted only PDF/JPG/PNG — a security vulnerability that e2e tests missed because they used the file-input programmatically, never simulating a drag-and-drop. At every organisation, the pattern was the same: the candidates who could articulate the component testing workflow — mount in isolation, mock dependencies, assert the rendered output, verify accessibility, catch visual regressions, run in 4 seconds — walked out with offers. The candidates who said "component testing is unit testing for UI" and could not go deeper did not.
Here is the reality: in 2026, component testing is not a niche practice. It is the standard answer to the hardest question in frontend testing — "how do you test 40 components in 5 seconds instead of testing 4 end-to-end flows in 8 minutes?" Every organisation that operates a modern frontend — retailers, banks, government departments, telcos — either uses Playwright Component Testing, Cypress Component Testing, or Testing Library, or is evaluating them. And interviewers know this. When they ask about component testing, they are not checking whether you can define "mount." They are checking whether you have used component tests to catch bugs that end-to-end tests never reach — and whether you can articulate the trade-offs between component tests, integration tests, and end-to-end tests with the fluency of someone who has designed a testing strategy for a real frontend application. SDET Interview Coach — Mitchell's iOS interview prep app with 800+ questions across 32 topics, Claude-graded mock interviews from Junior to Lead, and dedicated modules on component testing, frontend testing strategy, and the testing trophy model — gives you the structured practice to answer component testing questions with production-level fluency, for £4.99 per month on iOS.
What Interviewers Are Actually Testing When They Ask About Component Testing — It Is Never "Can You Define Component Testing?"
When an interviewer asks "explain how you would test a component in isolation using Playwright Component Testing," they are not checking whether you can recite the Playwright CT documentation: "Playwright Component Testing lets you mount and test individual components in a real browser, with full network interception, visual comparison, and accessibility assertions." That is a memorisation test — and memorisation does not get senior SDET offers. What the interviewer is actually testing is whether you understand that component testing is a testing strategy that sits between unit tests and end-to-end tests on the testing trophy — and that choosing where to place a test on that spectrum is a trade-off between speed, reliability, and confidence. The interview is testing four things: (1) can you explain the testing trophy model and why component tests are the largest slice — not unit tests and not end-to-end tests; (2) can you walk through mounting a component with Playwright CT or Cypress CT — including mocking child components, intercepting network requests, and asserting the rendered output, accessibility tree, and visual appearance; (3) can you articulate the Testing Library philosophy — why queries should be accessible-by-default (by role, label, text) rather than by CSS class or test ID — and explain how this approach catches accessibility bugs that CSS-selector-based tests miss; and (4) can you make a principled decision about when to mock a child component (because it has its own tests, its own network calls, or expensive rendering) versus when to render it in full (because the parent-child interaction is the thing you are testing).
Signal 1: You Understand the Testing Trophy — and Why Component Tests, Not Unit Tests, Are the Largest Slice
The strongest candidates understand that the testing trophy — popularised by Kent C. Dodds — inverts the traditional testing pyramid for frontend applications. The testing pyramid says: write lots of unit tests, some integration tests, and a few end-to-end tests. The problem: in frontend applications, unit tests that assert "function add(a, b) returns a + b" offer almost zero confidence. The real risk is not that a pure function returns the wrong value — it is that a component renders the wrong thing, in the wrong state, with the wrong accessibility attributes, under the wrong conditions. The testing trophy addresses this by making integration tests (which Kent C. Dodds defines as tests that render a component and assert its behaviour — essentially, component tests) the largest slice, with fewer unit tests for pure logic and even fewer end-to-end tests for critical user journeys. The one-line summary that signals mastery: 'The testing trophy says: static analysis at the base (TypeScript, ESLint), then unit tests for pure functions, then component integration tests as the largest slice — render the component, interact with it, assert its output — then a thin layer of end-to-end tests for critical happy paths. The reason component tests are the largest slice is that they give you 90% of the confidence of an end-to-end test at 1% of the runtime and 10% of the flakiness.' At Asda, Mitchell's team moved from a testing-pyramid approach (60% unit tests, 30% integration tests, 10% e2e tests) to a testing-trophy approach (20% unit tests for pure business logic, 60% component integration tests, 20% e2e tests for checkout and login flows). The result: the test suite runtime dropped from 18 minutes to 4 minutes, flaky-test tickets dropped from 12 per sprint to 1 per sprint, and the team caught 3x more regressions because component tests exercised the actual rendered output — not just function return values. The interview panel that heard this story made the offer on the spot.
Signal 2: You Can Mount a Component With Playwright Component Testing — mount(), Network Interception, and Component-Level Assertions
Playwright Component Testing (CT) provides a real browser environment for component tests — not jsdom, not a headless Node process, but a full Chromium/Firefox/WebKit browser that renders the component exactly as it appears in production. The strongest candidates can walk through the setup: install @playwright/experimental-ct-react (or the Vue/Svelte/Solid equivalent), configure playwright-ct.config.ts with the test directory and framework plugin, write a test that uses mount(<MyComponent prop={value} />) to render the component in the browser, and then assert the rendered output using standard Playwright locators — page.getByRole('button', { name: 'Submit' }), page.getByLabel('Email'), page.getByText('Welcome back'). But the mastery signal is going deeper: explaining that Playwright CT supports full network interception via page.route() — so you can mock API responses for data-fetching components without a separate mocking library; explaining that Playwright CT supports visual comparison with expect(page).toHaveScreenshot() — so you can catch visual regressions at the component level, not just the page level; explaining that Playwright CT supports accessibility assertions with expect(page).toPassAxeTests() (via the @axe-core/playwright integration) — so you can enforce ARIA compliance per component; and explaining that Playwright CT runs components in a real browser with real CSS layout, real event handling, and real rendering — which means you can test CSS grid layouts, :hover styles, @media queries, and prefers-reduced-motion behaviour that jsdom-based tools like Testing Library cannot test. The one-sentence summary: 'Playwright CT gives you the full browser — network interception, visual comparison, accessibility auditing, and real rendering — for component tests. Testing Library gives you jsdom — fast but not a real browser. The trade-off is runtime: Playwright CT takes longer per test than jsdom, but it catches visual, layout, and CSS bugs that jsdom cannot see.' At Nationwide, Mitchell's team used Playwright CT to test the mortgage calculator component — a complex form with real-time validation, API calls to the affordability service, and dynamic chart rendering. The component test suite ran in 8 seconds, caught a CSS grid misalignment that caused the monthly-payment label to overlap the input field on narrow viewports (a bug jsdom would never reproduce), and enforced ARIA labels on every input with toPassAxeTests() — all before the component reached a human tester.
Signal 3: You Understand the Testing Library Philosophy — Queries by Role, Label, and Text — Not CSS Selectors — and Why This Is Accessibility-First by Design
Testing Library's core philosophy is: "the more your tests resemble the way your software is used, the more confidence they can give you." In practice, this means queries are ordered by accessibility priority: getByRole (queries by ARIA role — the same way screen readers navigate the DOM), getByLabelText (queries by associated label — the way users with visual impairments find form inputs), getByPlaceholderText, getByText (queries by visible text — the way sighted users scan a page), and getByTestId (queries by a data-testid attribute — only when none of the above work). The interview signal is not that you can list these query methods — it is that you understand why getByRole is the default, why getByTestId is the escape hatch, and why a test that uses screen.getByRole('button', { name: 'Add to basket' }) is superior to a test that uses screen.getByTestId('add-to-basket-btn'). The first test validates that the button has the correct ARIA role and accessible name — if a developer removes the aria-label or changes the button text, the test fails. The second test only validates that a DOM element with data-testid="add-to-basket-btn" exists — it says nothing about whether a screen reader can identify it, whether a user can find it by visible text, or whether the button even renders visible text at all. The mastery signal is explaining that Testing Library's query hierarchy doubles as an accessibility lint — if you cannot query an element by role or label, the element is probably inaccessible, and the difficulty of writing the test reveals the accessibility problem. At the Co-op, Mitchell's team adopted Testing Library for component tests and discovered that 14 of the app's 25 components had at least one element that could only be queried by getByTestId because it lacked an ARIA role, a label, or visible text. Forcing the team to add ARIA attributes to make the components testable also made them accessible — and the app's Lighthouse accessibility score jumped from 72 to 96, entirely as a side-effect of adopting Testing Library's query philosophy. The panel that heard this story understood that the candidate was not just writing tests — they were engineering an accessible product through test design.
Signal 4: You Have a Mocking Strategy — When to Mock Child Components vs When to Render Them, and How to Use MSW at the Component Level
The hardest question in component testing is not "how do you mock?" but "when do you mock?" The weak answer: "I mock everything." This produces tests that pass when the component is broken — because the mock hides the real behaviour. The slightly better answer: "I never mock." This produces tests that are slow, brittle, and duplicate coverage across component boundaries. The mastery answer: "I mock child components when they have their own test suite, their own network dependencies, or expensive rendering — and I render them in full when the parent-child interaction is the thing I am testing." The interviewer then pushes: "Give me an example." The strong candidate says: "If I am testing a ProductCard component that contains a PriceDisplay child, I mock PriceDisplay because PriceDisplay has its own tests that verify price formatting, currency symbols, and sale-price display. Mocking PriceDisplay in ProductCard's tests means ProductCard's tests stay fast and focused — they test that the card layout is correct, that the 'Add to basket' button calls the correct handler, and that the image loads with the correct alt text. But if I am testing a Form component that contains a DatePicker child, I do not mock DatePicker — because the interaction between Form and DatePicker is exactly what I am testing: does the Form validate the selected date? Does it disable the submit button until a valid date is chosen? Does it clear the error message when a valid date is selected? Mocking DatePicker would hide the bugs I am trying to find." The mastery signal for network mocking: "For components that fetch data, I use MSW (Mock Service Worker) at the component level — it intercepts fetch requests in the same browser that Playwright CT or Testing Library uses, returns realistic response data, and lets me test loading states, error states, and success states without modifying the component code. MSW works with Playwright CT (via page.route() or MSW's service worker), with Cypress CT (via cy.intercept() or MSW), and with Testing Library (via MSW's Node server). The difference between MSW and page.route(): MSW gives you handler-based request matching (match by URL pattern, method, headers, body), response composition (merge defaults with overrides), and reuse across tests. page.route() gives you per-route interception in Playwright — more granular but more verbose. Strong candidates know both and can explain when each is appropriate." At BT, Mitchell's team used MSW at the component level to test the broadband-availability checker — a component that called three APIs (postcode lookup, address validation, availability check) and displayed results in a multi-step flow. MSW handlers mocked each API with realistic data, including edge cases: postcode not found, address not served by BT, availability check timeout. The component test suite — 28 tests covering loading states, error states, and every edge case — ran in 3 seconds. An equivalent set of end-to-end tests would have required seeding the address database, provisioning test broadband accounts, and running a 6-minute test suite — for the same coverage.
Core Concepts: The Component Testing Toolkit Every SDET Must Understand
After sitting on hundreds of SDET interview panels across HMRC, Nationwide, Accenture, and the Ministry of Defence, Mitchell has identified four core concepts that interviewers consistently probe. These are not "nice to know" — they are the difference between a candidate who says "I've heard of component testing" and one who can design a component testing strategy from scratch.
1. Component Testing vs E2E Testing vs Unit Testing — The Trade-Offs That Determine Where You Place Each Test
Component tests render a single component (or a small tree) in isolation, mock its external dependencies (APIs, child components, context providers), and assert the rendered output, user interactions, and accessibility. They run in 1–8 seconds per component. End-to-end tests start a full application — frontend, backend, database, third-party services — and simulate complete user journeys. They run in 1–10 minutes per journey. Unit tests test pure functions in isolation — no DOM, no rendering, no network. They run in milliseconds. The trade-off is the classic test-confidence triangle: unit tests are fastest but give the least confidence that the app works for a user; e2e tests give the most confidence but are slowest and flakiest; component tests sit in the sweet spot — fast enough to run on every commit, realistic enough to catch rendering bugs, interaction bugs, and accessibility bugs that unit tests miss. The interview question that tests this understanding: "Where would you test form validation logic — in a unit test, a component test, or an e2e test?" The weak answer: "All three." The strong answer: "The validation logic itself — the pure function that checks if an email matches a regex — in a unit test, because it is pure logic with no DOM dependency. The validation feedback — the error message that appears below the input, the red border, the ARIA error announcement — in a component test, because it requires rendering the component, triggering validation, and asserting the DOM output and accessibility tree. The complete form submission flow — fill in the form, submit, check the confirmation message — in an e2e test, because it exercises the full stack. Three test layers, each testing what they are best at."
2. Playwright Component Testing — Setup, mount(), Page vs Component Context, and the Gotchas
Playwright CT (experimental as of 2026) lets you mount React, Vue, Svelte, or Solid components in a real browser. The setup: npm install @playwright/experimental-ct-react, create playwright-ct.config.ts with testDir: './src' and the React plugin, write tests in files with the .spec.tsx extension. The core API: const component = await mount(<MyComponent />); returns a locator. Assertions use standard Playwright: await expect(component.getByRole('heading')).toHaveText('Dashboard');. The key difference from Playwright e2e: in e2e, you navigate to a URL and interact with a full page. In CT, you mount a single component — there is no URL, no page navigation, no routing. The three gotchas that separate experienced candidates from beginners: (1) the component runs in an iframe inside the Playwright test runner — so viewport and media-query tests need the iframe dimensions, not the page dimensions; (2) CSS is loaded via the framework plugin's bundler (Vite or webpack), not via a <link> tag — so CSS imports in component files must be handled by the bundler config; (3) Playwright CT's page object refers to the test runner page, not the component's iframe — you need page.frameLocator('iframe').locator(...) for advanced assertions, though mount()'s return value handles the iframe for you in most cases. At HMRC, Mitchell's team used Playwright CT to test the tax-return form stepper — a multi-step form with conditional sections, file upload, and summary review. The component test suite caught a bug where the "Previous" button in step 3 navigated to step 1 instead of step 2 — a state-management bug that only manifested when the component was rendered in a real browser with real React state, not jsdom. The test: await mount(<FormStepper />); await page.getByRole('button', { name: 'Next' }).click(); await page.getByRole('button', { name: 'Next' }).click(); await page.getByRole('button', { name: 'Previous' }).click(); await expect(page.getByRole('heading')).toContainText('Step 2'); — 4 lines, 1.8 seconds, caught a production bug.
3. Cypress Component Testing — cy.mount(), Component vs E2E Context, and the Cypress-Specific Patterns
Cypress Component Testing (stable since Cypress 10) provides a similar experience to Playwright CT: mount components in a real browser with full Cypress API access — cy.mount(), cy.get(), cy.intercept(), cy.spy(), cy.clock(). The setup: npm install cypress @cypress/react, configure cypress.config.ts with component settings (dev server, framework, bundler), write tests in *.cy.tsx files. The core API: cy.mount(<MyComponent />); mounts the component. The key difference from Cypress e2e: cy.visit() is not used — you mount components directly. cy.intercept() still works for network mocking. Spies and stubs are Cypress-native: const onClick = cy.spy().as('clickHandler'); cy.mount(<Button onClick={onClick} />); cy.get('button').click(); cy.get('@clickHandler').should('have.been.calledOnce');. The three Cypress-specific patterns that signal experience: (1) using cy.mount() with a wrapper component to provide context providers (Redux store, React Router, theme) — cy.mount(<Provider store={store}><MyComponent /></Provider>) — rather than mocking every context value individually; (2) using cy.clock() and cy.tick() to control timers for debounced inputs, animation timing, and setTimeout-based loading states — essential for components with timed behaviour; (3) using cy.fixture() to load test data from JSON files — keeping test data separate from test logic and reusing fixtures across multiple component test files. At Accenture, Mitchell's team used Cypress CT for a client's React dashboard application with 50+ components. The team used cy.mount() with a custom TestWrapper component that provided Redux store, React Router, and theme provider — so every component test started with a realistic context without duplicating setup code. The suite ran 200 component tests in 90 seconds — compared to 12 minutes for the equivalent e2e tests.
4. Testing Library — render(), Screen Queries, user-event, and jest-dom Matchers
Testing Library (React Testing Library, Vue Testing Library, etc.) renders components in jsdom — a pure JavaScript implementation of the DOM that runs in Node, not a real browser. The setup is simpler than Playwright CT or Cypress CT: npm install @testing-library/react @testing-library/jest-dom @testing-library/user-event. The core API: render(<MyComponent />) mounts the component in jsdom and returns queries (getByRole, getByText, etc.) bound to the rendered container. screen is a global object that provides the same queries without destructuring the render() return value — preferred because it mirrors how a user "sees" the entire screen. user-event (from @testing-library/user-event) simulates realistic user interactions — await user.click(button), await user.type(input, 'hello'), await user.keyboard('{Enter}') — with built-in delays and event sequences that match real browser behaviour (pointer down → pointer up → click, not just click). @testing-library/jest-dom provides DOM-specific matchers: toBeInTheDocument(), toHaveTextContent(), toBeVisible(), toBeDisabled(), toHaveAttribute(), toHaveClass(). The three patterns that signal Testing Library mastery: (1) always using screen over destructured queries — because screen represents the user's view of the rendered output and does not change when the component re-renders; (2) always using user-event over fireEvent — because fireEvent dispatches a single DOM event without the surrounding event sequence (e.g., fireEvent.click dispatches 'click' without 'pointerdown', 'pointerup', 'focus', etc.), which means components that rely on event sequences (most real components) can pass fireEvent tests but fail in real browsers; (3) using findBy* queries for async assertions — await screen.findByText('Loaded') waits up to 1000ms (configurable) for the text to appear, eliminating the need for manual waitFor calls in most cases. At the Co-op, Mitchell's team used Testing Library with user-event to test the membership registration form — a multi-step form with async validation (email uniqueness check, postcode lookup) and conditional sections. The user-event tests caught a bug where pressing Enter in the email field submitted the entire form instead of triggering the email-validation API call — a bug that fireEvent tests missed because fireEvent.keyDown does not simulate the form-submission behaviour that userEvent.keyboard('{Enter}') correctly reproduces.
The Common Mistakes That Expose Candidates Who Have Only Written End-to-End Tests
These are the traps that make interviewers lean back in their chairs and wait. They are not trick questions — they are the natural consequences of having tested only at the end-to-end level and never at the component level.
Mistake #1: "Component tests are just unit tests for UI — I can use the same approach."
No. Unit tests assert that f(x) returns y. Component tests assert that a rendered tree of elements has the correct structure, content, accessibility attributes, and behaviour after user interaction. The difference is not academic — it is the reason candidates who approach component tests like unit tests write assertions against implementation details (component state, internal function calls, prop values) instead of user-visible output (rendered text, ARIA roles, visual states, event handler effects). The interviewer will spot this when you say "I assert that the component's state is 'loading'" instead of "I assert that the loading spinner is visible and has role='status' and aria-label='Loading'." The first assertion tests implementation — if you refactor the state variable name from loading to isLoading, the test breaks. The second assertion tests behaviour — it passes regardless of how the component manages its internal state, as long as the user sees a loading spinner with the correct accessibility attributes. Testing implementation details is the number one reason component test suites become brittle and are eventually deleted.
Mistake #2: "I mock every child component — it keeps tests fast and isolated."
This is the most seductive trap in component testing. Mocking child components does keep tests fast — but it also hides integration bugs between parent and child. If you mock DatePicker in Form's tests, you will never catch the bug where Form passes the wrong date format to DatePicker. If you mock SearchInput in SearchPage's tests, you will never catch the bug where SearchPage debounces the search query incorrectly. The rule that signals mastery: mock leaf components (buttons, labels, spinners — components that have no behaviour of their own), mock components that make network calls (because those calls are tested in the component's own tests), but render components whose parent-child interaction you are testing. The interviewer will push you: "How do you decide the boundary?" The strong answer: "The boundary is the component's contract. If ChildComponent accepts props and calls callbacks, and ParentComponent's responsibility is to pass the correct props and handle the callbacks, then I mock ChildComponent and assert that ParentComponent passes the correct props and that the callback produces the correct effect. If ParentComponent and ChildComponent share state through a context provider, or if ChildComponent's behaviour depends on ParentComponent's render order, I render ChildComponent in full — because mocking would hide the shared-state bug." At BT, a candidate who said "I mock everything" was asked to walk through testing a SearchPage component with a SearchInput child, a ResultsList child, and a Pagination child. When the interviewer asked "what happens if SearchInput fires onChange with an empty string and ResultsList receives an empty query?" the candidate said "that can't happen because I mock SearchInput and pass the query directly to ResultsList." The interviewer pointed out that the bug was exactly in the interaction between SearchInput and ResultsList — the mocked test would never catch it. The candidate who said "I render SearchInput and ResultsList together in an integration test, and I mock Pagination because pagination is tested independently" got the offer.
Mistake #3: "I use CSS selectors to query elements — they mirror how the app is styled."
CSS selectors are the quickest way to write a component test and the fastest way to build a brittle test suite. A test that queries .btn-primary-large breaks when the designer renames the class to .btn-primary. A test that queries div > div > span:nth-child(3) breaks when the developer adds a wrapper div for layout. A test that queries [data-testid="submit"] passes — but says nothing about whether a screen reader can identify the button, whether a keyboard user can focus it, or whether the visible text matches the accessible name. The Testing Library approach — query by role, label, and text — is not a preference; it is a design constraint that forces accessibility. If a button has no accessible name, getByRole('button', { name: 'Submit' }) fails — and the test failure is telling you the button is inaccessible. CSS selectors never tell you this. At HMRC, Mitchell's team audited a component test suite that used CSS selectors — .govuk-button, .govuk-input, .govuk-error-message. The suite passed. The same components tested with Testing Library queries — getByRole('button', { name: 'Continue' }), getByLabel('National Insurance number'), getByRole('alert') — immediately revealed that 9 components had missing or incorrect ARIA attributes, 4 form inputs had no associated labels, and 2 error messages were not announced to screen readers. The CSS-selector tests had been silently passing over accessibility bugs for 18 months.
Mistake #4: "I test the happy path in components and leave edge cases to end-to-end tests."
This is the mistake that makes interviewers ask: "What happens when the API returns an empty array? What happens when the user's network is slow? What happens when the props are undefined?" The candidate who says "end-to-end tests cover edge cases" has missed the entire point of component testing: component tests are where you test edge cases, because they are fast enough to test every edge case. An end-to-end test that covers loading state, empty state, error state, success state, and timeout for a single component requires 5 separate test scenarios — each navigating through the app to reach the component. That is 40–60 minutes of test runtime for one component's edge cases. A component test that covers the same 5 states runs in 8–15 seconds total — because it mounts the component directly in each state, without navigation. The maths is brutal: 40 components × 5 states × 45 seconds (e2e) = 25 hours of test runtime. 40 components × 5 states × 3 seconds (component test) = 10 minutes of test runtime. Edge cases belong in component tests. Happy paths — the flows that must work end-to-end — belong in end-to-end tests. At Asda, Mitchell's team moved edge-case coverage from e2e tests to component tests and the e2e suite runtime dropped from 22 minutes to 6 minutes — without losing a single edge case. The interview panel that heard this strategy understood that the candidate was not just writing tests — they were engineering a test strategy that balanced speed and coverage.
Your 3-Step Component Testing Interview Prep Plan — From "I've Only Written E2E Tests" to "I Can Design a Component Testing Strategy"
You do not need 6 months. You need a focused plan that builds the right mental model and gives you the vocabulary to answer the questions interviewers actually ask. Here is the 3-step plan Mitchell has seen work for SDETs preparing for senior panels at HMRC, Nationwide, and the Ministry of Defence.
Step 1: Mount Your First Component (Tonight — 45 Minutes)
Do not read documentation. Write code. Pick the component testing framework you are most likely to encounter — Playwright CT if you are already a Playwright shop, Cypress CT if you are already a Cypress shop, Testing Library if you are framework-agnostic. Create a simple React component — a Counter with increment/decrement buttons and a display — and mount it. Write three tests: (1) renders the initial count as 0, (2) increments the count when the + button is clicked, (3) does not go below 0 when the - button is clicked at count 0. Use getByRole queries, userEvent (or Playwright's page.click()), and accessibility-first assertions. Then add a data-fetching component — a UserProfile that fetches from an API and displays a name and email. Mock the API with MSW or page.route(), test the loading state (spinner visible), the success state (name and email displayed), and the error state (error message displayed with role='alert'). This 45-minute exercise gives you the muscle memory to answer "walk me through mounting a component and testing its states."
Step 2: Build a Component Testing Decision Framework (Tomorrow Morning — 30 Minutes)
Interviewers do not just want to know that you can mount a component. They want to know that you can decide which components to test, how to test them, and when to use a component test versus an end-to-end test. Prepare a decision framework you can articulate in 90 seconds: "For every component, I ask three questions — (1) Does this component have user-visible states? If yes (loading, empty, error, success), those states are component tests. (2) Does this component interact with other components? If the interaction is a contract (props in, callbacks out), I test the parent with a mocked child, asserting the props and callbacks. If the interaction involves shared state or event bubbling, I render both components in an integration test. (3) Does this component have a visual or accessibility requirement? If yes (responsive layout, ARIA compliance, focus management), I use Playwright CT's visual comparison and axe accessibility checks — because jsdom cannot test layout or focus order." This framework — state coverage, interaction boundary, visual/accessibility requirement — signals that you think like a test architect, not just a test writer.
Step 3: Practise the Toughest Component Testing Questions (Ongoing — SDET Interview Coach)
The difference between a candidate who knows component testing and one who gets the offer is the ability to answer follow-up questions under pressure. "What do you lose when you mock a child component?" "When would you use Playwright CT over Testing Library?" "How do you test a component that uses React Context?" "How do you test a component that uses a WebSocket for real-time updates?" SDET Interview Coach — Mitchell's iOS app with 800+ SDET interview questions across 32 topics — includes a dedicated component testing topic area with questions calibrated to Junior, Mid, Senior, and Lead levels. The AI mock interviewer (powered by Claude) can run a dedicated component testing round, asking follow-up questions, scoring your answers on technical accuracy, completeness, communication, and code quality, and identifying the gaps you need to fill before the real interview. Use Job Match to paste a job description that mentions "component testing" or "Playwright CT" or "Testing Library" — the app generates 50 bespoke questions from that specific job spec, so you walk into the interview having practised the exact questions the panel is likely to ask. For £4.99 per month on iOS — less than the cost of the coffee you will drink while worrying about the interview — you can practise until "mount your first component" and "mock the API with MSW" feel like telling someone your name.
Visual Regression Testing at the Component Level — The Interview Question That Separates the Framework Designers From the Test Writers
By mid-2026, visual regression testing has moved from "nice to have" to "expected competency" at the senior SDET level. But the interview question that catches candidates off-guard is not "what is visual regression testing?" — it is "how would you implement visual regression testing at the component level, and how is it different from page-level visual testing?"
The weak answer: "I take a screenshot of the component and compare it to a baseline." This is technically correct but signals that the candidate has never implemented visual testing at scale. The strong answer: "Component-level visual testing is fundamentally different from page-level visual testing for three reasons. First, granularity: a page-level screenshot of a dashboard with 15 components fails when any component changes — and you have no idea which one. A component-level screenshot fails only when that specific component changes — and the diff pinpoints the change instantly. Second, isolation: a page-level screenshot captures layout shifts caused by unrelated components — a banner ad loading, a cookie consent popup, a live-chat widget. Component-level screenshots capture only the component under test, so environmental noise is eliminated. Third, speed: component-level screenshots are faster to capture (a component renders in milliseconds) and faster to compare (a 200×100px component vs a 1920×5000px page). The practical impact: a component-level visual regression suite with 200 components runs in 2 minutes. A page-level visual regression suite with 20 pages runs in 10 minutes and the failures tell you 'something changed somewhere on the page.'"
The mastery signal continues: "I use Playwright CT's toHaveScreenshot() for component-level visual testing. I configure a maxDiffPixels threshold — typically 100 pixels for a component — to allow sub-pixel rendering differences across operating systems. I use mask to exclude dynamic content (timestamps, randomly generated IDs, live data) from comparison. I run visual tests on Chromium for baseline and Firefox/WebKit for cross-browser validation — catching CSS inconsistencies that Testing Library's jsdom never reveals. And I integrate visual baselines into CI — baseline images are committed to the repository, diffs are uploaded as CI artifacts, and visual-regression failures block the PR merge." At Nationwide, Mitchell's team implemented component-level visual regression testing for the mortgage application's 35 components. The suite caught a CSS regression where a design-system update changed the button border-radius from 4px to 8px — a change that passed all functional tests (the button still clicked, the text was still visible), passed all accessibility tests (the button still had the correct ARIA role), and would have reached production if not for the component-level visual diff. The 4px → 8px change was intentional — but it broke the layout of 12 components that assumed a 4px border-radius. The visual regression test flagged all 12 components, the design-system team added backward-compatible classes, and the release shipped without a single visual regression.
Component Testing CI Pipeline Strategy — The Architecture Question That Tests Whether You've Done This in Production
Another 2026 interview differentiator: the CI pipeline question. Interviewers at senior panels ask "walk me through how you would set up a CI pipeline for a component test suite" not because they want to hear "I'd add a step to GitHub Actions." They want to hear that you understand the scaling challenges — caching, sharding, flakiness management, and the balance between pre-merge and post-merge testing.
The strong answer: "Component tests run on every PR. They are fast enough to gate merges — a 200-component suite runs in 2–4 minutes with parallel workers. I configure the CI pipeline in three stages. Stage 1: linting and type checking (TypeScript, ESLint) — 30 seconds, catches syntax and type errors before any test runs. Stage 2: unit tests for pure logic — 10 seconds, catches broken functions. Stage 3: component tests in parallel — Playwright CT or Cypress CT with sharding (split the test files across N workers), with a retry policy of 2 retries for flaky tests, with test artifacts (screenshots, traces, videos) uploaded on failure only. Stage 3 gates the merge — a component test failure blocks the PR. End-to-end tests run post-merge or on a schedule — they are too slow for pre-merge gating but too valuable to skip entirely."
The mastery details: "I use Playwright's sharding configuration — shard: '1/3' in GitHub Actions matrix — to split the test suite across workers. I use a shared build cache for dependencies (npm ci with caching) and Playwright browser binaries (cached between CI runs). For visual regression baselines, I use a dedicated CI job that updates baselines only on the main branch — PR branches compare against main's baselines, preventing visual drift. And I maintain a flaky-test dashboard — any test that fails on retry is logged with its failure trace, and the team reviews flaky tests weekly. A flaky test that cannot be stabilised is quarantined (moved to a separate suite) rather than deleted — because deleting a flaky test deletes the coverage it provided." At the Ministry of Defence, Mitchell's team implemented this exact CI strategy for a component test suite of 180 tests across 18 components. The pre-merge component test stage ran in 3 minutes, caught 94% of regressions before a human reviewer looked at the PR, and reduced the end-to-end test failure rate by 60% — because the bugs that would have reached the e2e stage were caught at the component stage instead.
Component Testing in 2026 — The Trends That Are Reshaping Interview Questions
If your component testing knowledge stops at "use Testing Library and jest-dom," you are answering 2023 questions in a 2026 interview. Here are the trends that panels are asking about right now.
- AI-generated component tests are here. Tools like Playwright's Codegen (now supporting component tests) and AI-assisted test generation (GitHub Copilot, Cursor) can generate component tests from component source code. The interview question is not "can AI write your tests?" — it is "how do you validate that an AI-generated test actually tests the right thing?" The answer: AI-generated tests are a starting point, not a finished product. A human reviews every AI-generated test for three things: (1) does it assert user-visible behaviour, not implementation details? (2) does it cover all user-visible states (loading, empty, error, success)? (3) does it use accessible queries (role, label, text) rather than generated CSS selectors or test IDs?
- Playwright CT is moving toward stable. As of 2026, Playwright CT is labelled "experimental" but is being used in production at organisations that value real-browser rendering for component tests. The interview question: "Playwright CT or Testing Library — which do you choose and why?" The strong answer: "Playwright CT when visual fidelity, CSS layout, or cross-browser behaviour matters — components with complex CSS, responsive layouts, or browser-specific behaviour. Testing Library when speed and simplicity are the priority — pure logic components, form validation, or components where the DOM structure matters more than the visual rendering. And I maintain both: Testing Library for fast pre-commit tests, Playwright CT for visual and cross-browser validation in CI."
- Accessibility testing is no longer optional. The European Accessibility Act (EAA) comes into full effect in June 2025, and UK regulations under the Equality Act 2010 require public-sector websites and apps to meet WCAG 2.1 AA standards. In 2026, interviewers at public-sector organisations (HMRC, MoD, NHS, local government) ask accessibility questions in component testing rounds by default. The question: "How do you enforce accessibility in component tests?" The answer: "I use jest-axe or @axe-core/playwright to run automated accessibility checks on every component. I assert that every interactive element has an accessible name —
getByRole('button', { name: /submit/i })— which fails at test time if the ARIA label is missing. I use Testing Library's query hierarchy (role → label → text → testId) to ensure that testability aligns with accessibility. And I run axe-core in CI — a component that fails axe checks fails the PR." - Component testing is converging with design systems. Organisations with component libraries (Storybook, Backstage, custom design systems) are integrating component tests directly into the component catalogue. The question: "How do you test components in a shared design system?" The answer: "Every component in the design system has a component test that validates its API (props → rendered output), its visual appearance (screenshot comparison against approved designs), its accessibility (axe checks), and its interactive behaviour (keyboard navigation, focus management, event handlers). These tests run in the design system's CI, not the consuming app's CI — because the design system is the source of truth, and a change to a design-system component that breaks a consuming app should be caught at the design-system level before the app even pulls the update."
Frequently Asked Questions About Component Testing for SDET Interviews
These are the questions Mitchell has been asked — and has asked candidates — in SDET interviews across two decades. The answers are what separate the candidates who get offers from the ones who get "we'll be in touch."
Ready to Transform Your Testing?
The AI Test Automation Playbook gives you everything you need: Playwright setup, Claude AI integration, MCP deep dive, 10+ ready-to-use prompts, CI/CD pipeline setup, and a 30-day implementation roadmap.
By Mitchell Agoma, Senior SDET & AI Testing Specialist with 8+ years of experience