Typescript 사용 시 dispatch와 selector 테스트하기

hailey·2022년 12월 9일
0

TIL

목록 보기
12/14

Typescript에서 dispatch랑 selector를 테스트 할 때 as jesk.Mock 을 붙이면 된다

그렇지 않으면 .mockImplementation이 타입이 없다고 계속 오류가 났었음

(useDispatch as jest.Mock).mockImplementation (() => dispatch);

(useSelector as jest.Mock).mockImplementation((selector) => selector({
//  sth..
}));

0개의 댓글