Bird
0
0

What will this test log?

medium📝 Predict Output Q5 of 15
Remix - Testing
What will this test log?
const { queryByText } = render(<div>Hello</div>);
const result = queryByText('World');
console.log(result);
AThe div element
BError thrown
Cnull
Dundefined
Step-by-Step Solution
Solution:
  1. Step 1: Understand queryByText behavior

    queryByText returns null if no matching element is found, unlike getByText which throws error.
  2. Step 2: Check if 'World' exists in rendered output

    Only 'Hello' is rendered, so queryByText('World') returns null.
  3. Final Answer:

    null -> Option C
  4. Quick Check:

    queryByText returns null if no match [OK]
Quick Trick: Use queryByText to safely check for missing elements [OK]
Common Mistakes:
MISTAKES
  • Expecting error instead of null
  • Confusing queryByText with getByText
  • Assuming undefined is returned

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes