rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.97k stars 867 forks source link

Jest snapshot is always created as null in react native #1449

Open chetangwl opened 1 year ago

chetangwl commented 1 year ago

I am trying to generate a snapshot using jest in React Native. But it always creates a null snapshot and also does not covers the file for code coverage. For reference please see the below code.

SignInScreen.test.tsx.snap

exports[renders correctly renders correctly sign in view 1] = null;

SignInScreen.test.tsx

import React from 'react'
import { Provider } from 'react-redux'
import renderer from 'react-test-renderer'
import { persistStore } from 'redux-persist'
import { PersistGate } from 'redux-persist/integration/react'
import store from '../../../store/store'
import SignInScreen from './SignInScreen'
const persistor = persistStore(store)

jest.useFakeTimers()

describe('renders correctly', () => {
    const wrapper = renderer.create(
        <Provider store={store}>
            <PersistGate loading={null} persistor={persistor}>
                <SignInScreen />
            </PersistGate>
        </Provider>,
    )
    it('renders correctly sign in view ', () => {
        expect(wrapper.toJSON()).toMatchSnapshot()
    })
})