Closed randycoulman closed 7 years ago
Something like this isnt really in the scope of this project. as the components youre looking to mock arent actually a part of react-native. However, instead of rolling your own mocking function, I recommend using https://github.com/mfncooper/mockery, it works great for exactly what youre doing!
Thank you for this project! It's been very helpful and works great!
While this project works for the core React Native components, it doesn't help with other native components (such as react-native-camera). However, the utilities and approach taken here work just fine with other components.
Is there any interest in exposing some utilities from this library, or extracting them to a different library and then using them from here?
I'm thinking particularly of
createMockComponent
and the code inmock.js
, but there may be other reusable helpers as well.In my project, I extracted a function out of
mock.js
that looks like this:Using this function,
mock.js
would end up looking like this:If this idea is of interest, let me know which direction you'd like to go (expose or extract), and I'll be happy to put together a PR.
Also, if you can identify any additional utilities that might be useful when mocking other libraries, point them out and I'll include them.