Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

useLocation in jest


const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
    ...jest.requireActual('react-router-dom'),
    useHistory: () => ({
        push: mockHistoryPush,
    }),
    useLocation: () => ({
        pathname: "/"
    })
}));
Comment

PREVIOUS NEXT
Code Example
Javascript :: React Unmounting Lifecycle Method 
Javascript :: jest array contain object with prop 
Javascript :: Javascript switch case code format 
Javascript :: js toggle boolean 
Javascript :: how to check the last item in an array javascript 
Javascript :: add variable numerically in javascript 
Javascript :: convert a string to an integer in javascript 
Javascript :: click outside box jquery 
Javascript :: dayjs timezone 
Javascript :: react native callback function uses default state value 
Javascript :: get element or class 
Javascript :: javascript string lentrh 
Javascript :: jquery switch class 
Javascript :: convert array to object in javascript 
Javascript :: bootstrap modal disable close on click outside react bootstrap 
Javascript :: set css variable from javascript 
Javascript :: route parammap subscribe angular 9 
Javascript :: material ui textfield error 
Javascript :: js check if dom element exists 
Javascript :: google oauth logout 
Javascript :: how to generate random rgb color number in javascript 
Javascript :: sum of numbers array using for loop in javascript 
Javascript :: js code stars 
Javascript :: compare and filter two array of object 
Javascript :: js get current function name 
Javascript :: celsius to fahrenheit in javascript 
Javascript :: how get checkbox if checked in jquery 
Javascript :: ant design not working in react js 
Javascript :: video preview javascript 
Javascript :: how to delete element at a particular index of array in react js 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =