블류_
chill days
블류_

블로그 메뉴

  • TIL
  • CS
  • 졸업작품[2018]
전체 방문자
오늘
어제
  • 분류 전체보기 (22)
    • logs (2)
      • 2018 (1)
    • TIL (17)
      • 졸업 작품 (3)
    • 책 (0)

공지사항

인기 글

최근 댓글

최근 글

hELLO · Designed By 정상우.
블류_

chill days

TIL

[Jest] 한 함수를 여러번 쓸경우, 여러 return 값이 필요시

2023. 5. 24. 18:36
반응형

https://jestjs.io/docs/mock-function-api#mockfnmockreturnvalueoncevalue

[Mock Functions · Jest

Mock functions are also known as "spies", because they let you spy on the behavior of a function that is called indirectly by some other code, rather than only testing the output. You can create a mock function with jest.fn(). If no implementation is given

jestjs.io](https://jestjs.io/docs/mock-function-api#mockfnmockreturnvalueoncevalue)

https://stackoverflow.com/questions/53887173/jest-mock-the-same-function-twice-with-different-arguments

[Jest mock the same function twice with different arguments

I'm new to JEST and I'm currently testing a Javascript component that makes an API call in its onComponentDidMount. Depending on the return data of the ajax call (api call) my component either disp...

stackoverflow.com](https://stackoverflow.com/questions/53887173/jest-mock-the-same-function-twice-with-different-arguments)

jest 의 mockReturnOnce기능을 이용하면됨

저작자표시 (새창열림)

'TIL' 카테고리의 다른 글

S3 CopyObject / Access Deny / the specified key does not exist  (0) 2023.08.03
prisma 5 update 주요 내용  (0) 2023.07.12
rxjs retry change parameter / rxjs retry 사용시 값 갱신 안됨  (0) 2023.05.16
Class-validator @Transform 사용시 @ValidateNested 동작 안함 ValidatedNested with transform not validating  (0) 2023.04.04
eslint : vscode formatOnSave  (0) 2023.02.16
    'TIL' 카테고리의 다른 글
    • S3 CopyObject / Access Deny / the specified key does not exist
    • prisma 5 update 주요 내용
    • rxjs retry change parameter / rxjs retry 사용시 값 갱신 안됨
    • Class-validator @Transform 사용시 @ValidateNested 동작 안함 ValidatedNested with transform not validating
    블류_
    블류_
    github : https://github.com/eclatchung

    티스토리툴바