-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support snapshots of many views (#6047)
## 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 #6084
- Loading branch information
Showing
25 changed files
with
741 additions
and
524 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/Asserts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
import { RUNTIME_TEST_ERRORS } from './stringFormatUtils'; | ||
import { TestCase, TestSuite } from './types'; | ||
import type { TestCase, TestSuite } from './types'; | ||
|
||
export function assertMockedAnimationTimestamp(timestamp: number | undefined): asserts timestamp is number { | ||
'worklet'; | ||
if (timestamp === undefined) { | ||
throw new Error(RUNTIME_TEST_ERRORS.NO_MOCKED_TIMESTAMP); | ||
throw new Error("Seems that you've forgot to call `mockAnimationTimer()`"); | ||
} | ||
} | ||
|
||
export function assertTestSuite(test: TestSuite | null): asserts test is TestSuite { | ||
if (!test) { | ||
throw new Error(RUNTIME_TEST_ERRORS.UNDEFINED_TEST_SUITE); | ||
throw new Error('Undefined test suite context'); | ||
} | ||
} | ||
|
||
export function assertTestCase(test: TestCase | null): asserts test is TestCase { | ||
if (!test) { | ||
throw new Error(RUNTIME_TEST_ERRORS.UNDEFINED_TEST_CASE); | ||
throw new Error('Undefined test case context'); | ||
} | ||
} |
244 changes: 0 additions & 244 deletions
244
apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/Matchers.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
apps/common-app/src/examples/RuntimeTests/ReanimatedRuntimeTestsRunner/TestComponent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.