백스테이지

  • 홈
  • 태그
  • 방명록

Javascript 2

jest const 변수 mock 하는 방법

요즘 전에 했던 프로젝트들을 리팩토링 하고, 시간 부족으로 인해 중간중간 비어있는 test code들을 작성 중이다. 오늘은 express, jest, typescript를 사용하여 진행했던 commerce platform clone 프로젝트 테스트 코드를 작성 중 해결했던 문제에 대해 기록하려 한다. signup의 service layer test 코드 작성 중 비밀번호를 해싱과 관련된 함수들을 따로 util 폴더에 분리시켜놨었는데 아래 함수를 mocking 하려다가 오류가 발생했다. const encryptPassword = async (password: string) => { ... encryptPassword가 const로 선언되어 있기 때문에 mock으로 재할당 할 수 없었다. 전에 javasc..

카테고리 없음 2022.11.22

nestjs jest unit test 'Cannot find module' 문제 해결

Nestjs로 진행한 프로젝트에서 jest를 사용하여 unit test를 해보려고 했는데 오류가 발생했다. 현재 나의 코드는 testing module 생성만 해놓은 상황이었다. beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ controllers: [BossRaidController], providers: [ { provide: BossRaidService, useFactory: mockBossraidService, }, ], }).compile(); controller = module.get(BossRaidController); service = module.get(BossRaidService..

카테고리 없음 2022.11.21
이전
1
다음
더보기
  • 분류 전체보기 (9)

최근글과 인기글

  • 최근글
  • 인기글

Tag

WITH절, Mock, heap, 프로그래머스, 알고리즘, level3, SSG, 블로그이전, nest, Javascript, 스택, HTTPS, nestjs, 코딩테스트, jest, Python, Mocking, SSR, TypeScript, 입양시각구하기,

Copyright © Kakao Corp. All rights reserved.

티스토리툴바