이번에야말로 모킹을 통해 유닛테스트를 작성해보자. 왜 필요한가? 솔직히 이걸 제대로 이해하지 못해서 계속 모킹이라는 것을 이해하지 못했던 것 같다. https://0422.tistory.com/294 Docker compose로 테스트 코드 환경 구성하기(express + TypeORM) - typeORM, Jest 설정 컨테이너 설정은 다했으니 TypeORM과 Jest의 설정을 해보자. Data-Source.ts 일단 나는 DataSource방식으로DAO코드를 작성했다. https://orkhan.gitbook.io/typeorm/docs/data-source Working with DataSource - typeorm Generally, you ca 0422.tistory.com 이전에 적었던 글을 ..
TDD
컨테이너 설정은 다했으니 TypeORM과 Jest의 설정을 해보자. Data-Source.ts 일단 나는 DataSource방식으로DAO코드를 작성했다. https://orkhan.gitbook.io/typeorm/docs/data-source Working with DataSource - typeorm Generally, you call initialize method of the DataSource instance on application bootstrap, and destroy it after you completely finished working with the database. In practice, if you are building a backend for your site and you..
드디어 도커 컨테이너를 활용해서 테스트코드를 작성해보자. 로컬에서 db를 비우고, 테스트하고, 다시 비우면 너무 일이 많으므로, test시도시에 컨테이너를 띄우고, 모든 테스트를 완료한 후에 컨테이너를 내리는 식으로 테스트를 진행할 것이다. 일단 docker-compose.yml을 작성해서 mySQL 컨테이너를 하나 띄워주자 version: '3' services: mySQLContainer: image: mysql container_name: mySQLContainer command: - --default-authentication-plugin=mysql_native_password - --character-set-server=utf8 - --collation-server=utf8_general_ci ..