1. Junior

    What is the philosophy of React Testing Library (RTL), and how does it differ from the old Enzyme tests?

    RTL tests components as real users interact with them (using text, buttons, and accessibility roles), instead of testing internal implementation details such as State and Class Methods.

    Read the full explanation
  2. Junior

    How do getBy, queryBy, and findBy queries differ in React Testing Library?

    getBy immediately returns an element or throws if missing; queryBy returns null if missing (useful for checking absence); findBy is asynchronous and waits for an element to appear (for Promises and animations).

    Read the full explanation
  3. Mid-level

    Why prefer userEvent over fireEvent when testing user interactions?

    userEvent simulates a full sequence of realistic browser events (such as hover, focus, keydown, and input), while fireEvent triggers only the target event in isolation.

    Read the full explanation
  4. Mid-level

    What is Mock Service Worker (MSW), and why is it the gold standard for testing API requests in React?

    MSW intercepts requests at the Network Layer with a Service Worker or Node.js interceptors without changing the application's original fetch calls.

    Read the full explanation
  5. Senior

    What is the common "act(...) warning", why does it appear, and how should you fix it?

    It appears when a component state update happens outside act(), usually because an asynchronous operation (Promise or Timer) finishes after the test has stopped checking.

    Read the full explanation
  6. Mid-level

    How do you test a Custom Hook separately with RTL's renderHook?

    Call renderHook(() => useCustomHook()), which creates a test component to run the Hook and returns a result object with its current value and a rerender method.

    Read the full explanation
  7. Mid-level

    How do Component Tests differ from Playwright end-to-end (E2E) tests?

    Component tests check an isolated UI unit in a simulated DOM environment (jsdom), while E2E tests run a real browser and test the full user journey across the server and real interface.

    Read the full explanation
  8. Junior

    How do you test components that depend on React Context without running the entire application?

    Wrap the target component in the required Context.Provider inside render and supply test-specific mock data.

    Read the full explanation
  9. Junior

    What is Snapshot Testing, and what are the risks of overusing it?

    It compares a component's DOM structure with a previously saved text snapshot; overuse leads to fragile tests that are updated automatically after every small change without reviewing what changed.

    Read the full explanation
  10. Mid-level

    How do you test accessibility in React components with axe-core?

    Integrate jest-axe into component tests to scan the rendered DOM and confirm that it has no WCAG violations.

    Read the full explanation