Skip to main content
InterviewHubPRO
Section Overview
Q16

Question 16 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

32%
Software Testing & QA (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

Testing Library Philosophy: Testing User Behavior vs. Implementation Details.

senior LevelTestingSystem Design

In Simple Words: Kent C. Dodds' guiding principle: "The more your tests resemble the way your software is used, the more confidence they can give you."

  • Implementation Details to Avoid:
    • Testing component state variable names (wrapper.state('isOpen')).
    • Querying by internal CSS classes (.btn-primary).
  • User Behavior Queries (in priority order):
    1. getByRole('button', { name: /submit/i }) (reflects accessibility tree).
    2. getByLabelText('Email Address').
    3. getByPlaceholderText('Search...').
    4. Fallback: getByTestId('checkout-form').