가짜 함수를 만들지 않고 실질적인 함수를 사용해야할 때가 있다
이때 이함수의 호출 횟수나 어떻게 호출되었는지 알고 싶을때 필요하다
const caculator={
add:(a:number,b:number)=>a+b
}
test("스파이 on!",()=>{
const spyFn=jest.spyOn(caculator,"add")
const result =caculator.add(2,4);
expect(spyFn).tobeCalledTimes(1)
expect(spyFn).toHaveBeenCalledWith(2,4)
expect(result).toBe(6)
})