Skip to content

Conversation

@Latropos
Copy link
Contributor

@Latropos Latropos commented May 27, 2024

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:

  • Organise logic of matcher functions:
    • Move rawMatchers into separate file
    • Move snapshot matchers into separate file
  • Clean up error log of snapshot mismatch and format as an array:
Screenshot 2024-06-06 at 16 23 20

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 #6084

@Latropos Latropos mentioned this pull request Jun 6, 2024
@Latropos Latropos requested a review from piaskowyk June 6, 2024 14:24
@Latropos Latropos marked this pull request as ready for review June 6, 2024 14:24
Base automatically changed from acynk/fix-runtime-tests-for-monorepo to main June 14, 2024 10:46
@Latropos Latropos requested a review from piaskowyk June 17, 2024 14:10
@Latropos Latropos added this pull request to the merge queue Jun 17, 2024
Merged via the queue into main with commit c41eee5 Jun 17, 2024
@Latropos Latropos deleted the acynk/test-sequence branch June 17, 2024 14:56
r0h0gg6 pushed a commit to r0h0gg6/react-native-reanimated that referenced this pull request Jul 28, 2025
## 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:
* Organise logic of matcher functions:
  * Move rawMatchers into separate file
  * Move snapshot matchers into separate file
* Clean up error log of snapshot mismatch and format as an array:
<img width="625" alt="Screenshot 2024-06-06 at 16 23 20"
src="https://github.com/software-mansion/react-native-reanimated/assets/56199675/c239e65c-d71a-44af-83cd-c3256da1d51f">

 
## 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
software-mansion#6084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants