인프런 커뮤니티 질문&답변
Jest 에러 테스트 관련해서 질문드립니다.
작성
·
187
0
expect({ ...new HttpException('dg', 400) }).toMatchObject({
...new HttpException('dg', 500),
});
expect(new HttpException('dg', 400) }).toMatchObject(
new HttpException('dg', 500),
);
위에 테스트는 통과가 되지만 아래코드는 통과가 되지않는데 그이유를 알수있을까요..
또 service단 unit테스트를 진행할때
예를들어
async getUser({ id }: Pick<Parameter, 'id'>) {
const user = await this.userRepository.find({
where: {
status: 'ACTIVE',
id,
},
});
if(!user){
throw new HttpException("존재하지않는 유저입니다.", 400);
}
return user;
}이것에대한 테스트중 유저가 존재하지않을 경우를 테스트하고싶은데 try catch 이용하는것말고는 방법이 없을까요?
답변
답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!





.png?w=112)