Jest Mocking react-native-mmkv
Hi,
is there a way or provided way to easily mock this great library?
would be great if we can provide mocks directly from the library similar way to how AsyncStorage does
Thanks!
Hey, this seems to be very weird to let the user set up all of this - I think there's better examples (e.g. Reanimated) that automatically mock everything
@mrousavy, yeah that looks simpler. Anything that will help other people using this package so that we dont need to look else where or make our own mocking.
Sure, if you shoot me a PR I'll be happy to review, test and merge it :)
Hey! I think mocking should now work! Thanks everyone! :)
Add a wrapper provider to your App/Component
import { Provider } from 'react-redux';
import store from '../stores/store';
export const renderWithProviderTheme = (component: React.ReactElement) => {
const { debug, ...rest } = render(
<Provider store={store}>{component}</Provider>,
);
return {
debug,
...rest,
};
};
import { renderWithProviderTheme } from '...';
describe('Render with provider, store(mmk)', () => {
test('Should render correctly component', () => {
renderWithProviderTheme(
<MyComponent/>,
);
});