Recall & Review
beginner
What is component testing in React Native?
Component testing checks if a single UI component works correctly by itself, without involving the whole app.
Click to reveal answer
intermediate
Why do we use shallow rendering in component testing?
Shallow rendering tests a component without rendering its child components, making tests faster and focused.
Click to reveal answer
beginner
Which library is commonly used for React Native component testing?
React Native Testing Library is popular because it encourages testing components like users interact with them.
Click to reveal answer
intermediate
What does a snapshot test do in component testing?
A snapshot test saves the rendered output of a component and compares it later to detect unexpected changes.
Click to reveal answer
intermediate
How can you simulate a button press in React Native component tests?
You can simulate a button press by firing a press event using fireEvent.press from React Native Testing Library.
Click to reveal answer
What is the main goal of component testing in React Native?
✗ Incorrect
Component testing focuses on checking one UI component alone to ensure it works as expected.
Which method helps to avoid rendering child components during tests?
✗ Incorrect
Shallow rendering renders only the component itself, not its children, making tests simpler.
Which library is best suited for user-focused React Native component testing?
✗ Incorrect
React Native Testing Library encourages testing components as users interact with them.
What does a snapshot test compare?
✗ Incorrect
Snapshot tests compare the saved rendered output to the current output to catch changes.
How do you simulate a button press in React Native Testing Library?
✗ Incorrect
fireEvent.press simulates a press event on a button in React Native Testing Library.
Explain the purpose and benefits of component testing in React Native.
Think about testing one piece of the UI alone before the whole app.
You got /4 concepts.
Describe how you would write a simple test to check if a button press calls a function in React Native.
Use React Native Testing Library and fireEvent.press.
You got /4 concepts.