Object
jest.spyOn(object, methodName)
함수 덮어쓰기
const video = {
play() {
return true;
},
};
export default video;import video from "./video";
afterEach(() => {
jest.restoreAllMocks();
});
test("plays video with mock implementation using jest.spyOn", () => {
const spy = jest.spyOn(video, "play").mockImplementation(() => false);
const isPlaying = video.play();
expect(spy).toHaveBeenCalled();
expect(isPlaying).toBe(false);
});using 키워드와 함께
getter 와 setter
Last updated