Skip to content

Commit fd01fff

Browse files
docs: Add info about testing react-native-svg with Reanimated (#8389)
## Summary As the title declares, we added info for users how the can mock the react-native-svg library - because it's common problem with Reanimated and Jest. <img width="905" height="450" alt="image" src="https://github.com/user-attachments/assets/a26cc9fe-9034-4128-8eb6-1b77c47eadab" /> ## Test plan
1 parent 878e27a commit fd01fff

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/docs-reanimated/docs/guides/testing-with-jest.mdx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,17 @@ More examples from `react-native-reanimated` repository:
111111
- [SharedValue.test.tsx](https://github.com/software-mansion/react-native-reanimated/tree/main/packages/react-native-reanimated/__tests__/SharedValue.test.tsx)
112112
- [Animation.test.tsx](https://github.com/software-mansion/react-native-reanimated/blob/main/packages/react-native-reanimated/__tests__/Animation.test.tsx)
113113

114+
## Testing `react-native-svg`
115+
116+
Because of how `react-native-svg` manages its props, you need to use the mock provided by Reanimated to enable testing:
117+
118+
```js
119+
jest.mock('react-native-svg', () => require('react-native-reanimated/mock'));
120+
```
121+
114122
## Remarks
115123

116124
- Tests must run with Node 16 or newer.
117-
- Testing `react-native-svg` props is not supported.
118125
- If you have custom babel configuration for testing, make sure that Reanimated's babel plugin is enabled in that environment.
119126

120127
## Recommended testing library

0 commit comments

Comments
 (0)