Quantcast
Channel: How to mock useHistory hook in jest? - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by Henry Tipantuña for How to mock useHistory hook in jest?

0
0

This works for me, I was having problems with useLocation too

jest.mock('react-router-dom', () => ({  useHistory: () => ({    push: jest.fn()  }),  useLocation: jest.fn().mockReturnValue({    pathname: '/another-route',    search: '',    hash: '',    state: null,    key: '5nvxpbdafa'})}))

Viewing all articles
Browse latest Browse all 9

Latest Images

Trending Articles





Latest Images