-
Notifications
You must be signed in to change notification settings - Fork 28
(Jest, Supertest) API 단위 통합 테스트
Sungdong Jo edited this page Nov 13, 2019
·
2 revisions
import httpMocks from "node-mocks-http";
import status from "http-status";
import { findHouse } from "../../../middleware/house";
describe("Middleware - House", () => {
it("[체크인/체크아웃, 인원, 가격] 필터로 조회 후 결과를 반환한다.", async () => {
// given
const query = {
checkInOut: [
new Date("2016-10-01 00:00:00 GMT+0900"),
new Date("2016-10-03 00:00:00 GMT+0900")
],
capacity: [3],
price: [0, 100]
};
const req = httpMocks.createRequest({
query
});
const res = httpMocks.createResponse();
const next = jest.fn();
// when
await findHouse(req, res, next);
// then
expect(res.get("Content-Type")).toEqual("application/json");
expect(res.json()).toEqual(/* 기대하는 결과 값 */);
expect(res.statusCode).toEqual(status.OK);
});
});
import supertest from "supertest";
import status from "http-status";
const agent = supertest.agent("http://localhost");
describe("Routes - House", () => {
test("GET /house", async () => {
// given
const query = {
checkInOut: [
new Date("2016-10-01 00:00:00 GMT+0900"),
new Date("2016-10-03 00:00:00 GMT+0900")
],
price: [0, 800],
capacity: [3]
};
// when
const response = await agent.get("/house").query(query);
// then
expect(response.header["content-type"]).toEqual(
"application/json; charset=utf-8"
);
expect(response.body.length > 0).toBeTruthy();
expect(response.statusCode).toEqual(status.OK);
});
});
실용적인 리액트 테스트 전략
DevOps
Infra Structure
컴포넌트 작성법
Client Sturcture
데이터베이스 스키마
Yarn workspace 명령어
Docker를 이용한 서버 개발 환경
Linting Tools