Bird
0
0

Given this test snippet, what will be the output?

medium📝 Predict Output Q4 of 15
Remix - Testing
Given this test snippet, what will be the output?
const { getByText } = render(<button>Click me</button>);
const button = getByText('Click me');
console.log(button.tagName);
A'BUTTON'
B'DIV'
C'SPAN'
DError: getByText not found
Step-by-Step Solution
Solution:
  1. Step 1: Understand render output

    Rendering <button>Click me</button> creates a button element with text 'Click me'.
  2. Step 2: getByText returns the button element

    getByText('Click me') finds the button element, so button.tagName is 'BUTTON'.
  3. Final Answer:

    'BUTTON' -> Option A
  4. Quick Check:

    getByText returns element with matching text [OK]
Quick Trick: getByText returns the actual element with that text [OK]
Common Mistakes:
MISTAKES
  • Expecting tagName to be lowercase
  • Confusing button with div or span
  • Thinking getByText returns error if element exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Remix Quizzes