software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.61k stars 1.27k forks source link

Support snapshots of many views #6047

Closed Latropos closed 2 weeks ago

Latropos commented 1 month ago

Summary

Previously recording snapshots of component containing multiple views were generating array of all the updates in random order.

The new API is as follows:

const component = getTestComponent('ComponentRed');
expect(updatesContainer.getUpdates(component)).toMatchSnapshots(Snapshots.component);

If you don't specify any component, but snapshot recorded more than one an error is thrown. Same if you specify a component, but there is only one recording.

Other changes in this PR include:

Test plan

File Animations.test.tsx was renamed into TestsOfTestingFramework.test.tsx, include some tests of snapshot mismatch (and mismatch of callback functions) Tested on Paper, on IOS and Android. Some of the fixes, created to make tests work well on Android, were extracted into separate PR https://github.com/software-mansion/react-native-reanimated/pull/6084