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).
- Testing component state variable names (
- User Behavior Queries (in priority order):
getByRole('button', { name: /submit/i })(reflects accessibility tree).getByLabelText('Email Address').getByPlaceholderText('Search...').- Fallback:
getByTestId('checkout-form').