worldint
mathengi
worldint
전체 방문자
오늘
어제
  • 분류 전체보기 (152)
    • infra, cloud (4)
      • aws (4)
    • TIL,WIL(일간,주간 회고) (57)
    • 컴퓨터 공학 (5)
      • 정보통신 (3)
      • 컴퓨터 구조 (2)
    • Math (1)
      • linear algebra (0)
      • 명제와 집합 (1)
    • Operating System (8)
      • Linux Ubuntu (1)
    • programming (66)
      • c , c++ (9)
      • c# (0)
      • java (2)
      • javascript (14)
      • Python (4)
      • github (1)
      • programing terms (12)
      • html, css (2)
      • docker (3)
      • algorithm_datastructure (5)
      • database (11)
      • flutter(dart) (2)
    • 항해99 부트캠프 (7)
      • 사전교육 (7)
    • 보안관련 (1)

블로그 메뉴

    공지사항

    인기 글

    태그

    • docker
    • 디비데드락
    • NVM
    • ec2 #코드디플로이 #리눅스
    • AWS
    • Blue/Green
    • MONGOOSE
    • MongoDB
    • EC2
    • CloudFront
    • NoSQL
    • ci/cd
    • nodejs
    • flutter #provider #error
    • node
    • db데드락
    • Javascript

    최근 댓글

    최근 글

    티스토리

    hELLO · Designed By 정상우.
    worldint

    mathengi

    TIL,WIL(일간,주간 회고)

    jest로 Logger.log 테스트

    2023. 4. 24. 18:49

    로그가 잘뜨는지 확인 하는 테스트코드 작성

    컨트롤러.ts

    @Controller()
    export class LoggerTestController {
      readonly logger = new Logger('LoggerTest.contoller');
    
      test(){
      this.logger.log("이게 나와야된다");
      return { value:"리턴은 이거"};
      }
     
    }

     

    컨트롤러.spec.ts

    describe('컨트롤러', () => {
      let controller: LoggerTestController;
      let service: LoggerTestService;
    
      beforeAll(async () => {
        const MockModule: TestingModule = await Test.createTestingModule({
          controllers: [LoggerTestController],
          providers: [
            {
              provide: LoggerTestService,
              useClass: MockLoggerTestService,
            },
          ],
        }).compile();
    
        controller = MockModule.get<LoggerTestController>(LoggerTestController);
        service = MockModule.get<LoggerTestService>(LoggerTestService);
      });
    
      it('post성공했을 때 로그 띄워줘야함', async () => {
        const spylog = jest.spyOn(controller.logger, 'log').mockReturnValue();
        await controller.test();
        expect(spylog).toHaveBeenCalledWith('OO님이 상품을 등록을 하셨습니다');
      });
    });

    'TIL,WIL(일간,주간 회고)' 카테고리의 다른 글

    TIL interface 교차타입  (0) 2023.05.30
    [vscode]에서 파일 변화 인식 못할 때  (0) 2023.05.12
    dotenv사용할때 알게된점  (0) 2023.04.17
    cannot find type definition file for 'morgan'. the file is in the program because:\n entry point for implicit type library 'morgan'  (0) 2023.04.17
    sourcetree(소스트리) 클론시 올바른 원본 경로 url이 아니라고 뜰 때  (0) 2023.04.17
      'TIL,WIL(일간,주간 회고)' 카테고리의 다른 글
      • TIL interface 교차타입
      • [vscode]에서 파일 변화 인식 못할 때
      • dotenv사용할때 알게된점
      • cannot find type definition file for 'morgan'. the file is in the program because:\n entry point for implicit type library 'morgan'
      worldint
      worldint
      공부한 내용들, 트러블 슈팅, 아티클 번역 등등 올리는 블로그입니다

      티스토리툴바