Search code examples
reactjsunit-testingreact-reduxjestjsts-jest

Jest test of RootState


I have been trying to write a jest Unit test for the following line, and cant figure it out. This is React using Redux

export const someState = (state: RootState) => {state.someStore}

I have tried everything I can think of, SpyOn, mock, calling directly. I can get it to pass, but when I run a coverage report, this line is never actually tested.


Solution

  • it('some title', () => {
      const state = {
        someState: RootState {
          someStore: {
            data: ''
          }
        }
      }
    
     expect(someState(state)).toBe(state.someStore)
    })
    

    Thanks ChatGPT