Recall & Review
beginner
What is snapshot testing in React Native?
Snapshot testing captures the rendered output of a component and saves it as a file. Later, it compares the current output to the saved snapshot to detect unexpected changes.
Click to reveal answer
beginner
How do you create a snapshot test for a React Native component?
You render the component using a test renderer, then use expect(tree).toMatchSnapshot() to save or compare the snapshot.
Click to reveal answer
beginner
Why is snapshot testing useful in mobile app development?
It helps catch UI changes early by comparing the current UI output to a saved version, preventing accidental visual bugs.
Click to reveal answer
intermediate
What should you do if a snapshot test fails because of an intentional UI change?
Review the changes and if they are expected, update the snapshot file by running the test command with the update flag (e.g., jest -u).
Click to reveal answer
intermediate
Name one limitation of snapshot testing.
Snapshot tests can pass even if the UI looks wrong, because they only compare output text, not actual rendered visuals or user experience.
Click to reveal answer
What does a snapshot test compare in React Native?
✗ Incorrect
Snapshot tests compare the current rendered output of a component to a previously saved snapshot file to detect changes.
Which command updates snapshot files when UI changes are intentional?
✗ Incorrect
The jest -u command updates snapshot files to reflect intentional UI changes.
Snapshot testing is best described as:
✗ Incorrect
Snapshot testing checks if the UI output matches a saved snapshot to catch unexpected changes.
What tool is commonly used for snapshot testing in React Native?
✗ Incorrect
Jest is the testing framework commonly used for snapshot testing in React Native.
If a snapshot test fails unexpectedly, what should you do first?
✗ Incorrect
You should review the UI changes to confirm if they are intentional before updating snapshots.
Explain how snapshot testing helps maintain UI consistency in React Native apps.
Think about how saving and comparing UI output can catch bugs.
You got /4 concepts.
Describe the steps to write and update a snapshot test for a React Native component.
Focus on the test code and commands used.
You got /4 concepts.