0
0
React Nativemobile~5 mins

Snapshot testing in React Native - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AThe rendered component output to a saved snapshot file
BThe app's performance metrics
CThe network requests made by the app
DThe app's database contents
Which command updates snapshot files when UI changes are intentional?
Ajest --watch
Bjest -u
Cnpm start
Dreact-native run-ios
Snapshot testing is best described as:
AValidating backend API responses
BTesting app performance under load
CTesting user interactions manually
DChecking if UI output matches a saved version
What tool is commonly used for snapshot testing in React Native?
AJest
BRedux
CExpo
DFirebase
If a snapshot test fails unexpectedly, what should you do first?
AIgnore the failure
BDelete the snapshot file
CReview the UI changes to confirm if they are intentional
DRestart the device
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.