Woozy_DevLog
article thumbnail
Carryduo 테스트코드
Project/Carryduo 2023. 3. 21. 21:43

Error 테스트 하기 champ의 데이터를 제공하는 api에서 데이터베이스에 존재하지 않는 챔피언id로 요청을 보낼 경우에 대한 예외처리를 테스트를 작성한다. it('getTargetChampion은 존재하지 않는 챔피언id를 받으면 error return?', async () => { let error = null; const Param = { champId: '4', position: 'default', }; try { await service.getTargetChampion(Param); } catch (err) { error = err; } expect(error).not.toBeNull(); }); try catch 문을 이용하여 error가 발생했는지 여부를 not.tobeNull() 메서드..