B. Not passing initial count prop to Counter component
C. Incorrect query getByText for the button label
D. Using button.click() instead of fireEvent.click(button)
Solution
Step 1: Check how user events are simulated
Testing Library requires using fireEvent or userEvent to simulate clicks, not direct button.click() calls.
Step 2: Verify other parts of the test
Counter is imported, getByText queries are correct, and initial props are optional here.
Final Answer:
Using button.click() instead of fireEvent.click(button) -> Option D
Quick Check:
Use fireEvent for clicks, not button.click() [OK]
Hint: Use fireEvent or userEvent for clicks, not element.click() [OK]
Common Mistakes:
Calling element.click() directly instead of fireEvent
Forgetting to import the component
Using wrong text in getByText query
5. You want to test a Svelte component that conditionally shows a message only after a button click. Which Testing Library approach correctly waits for the message to appear before asserting?