기본구조는 jest와 같다.
매크로 짜듯이 하고싶은 테스트 내용을 나열하면 된다.
describe("통합 테스트 제목", () => {
it("테스트 제목", () => {
// cypress 명령어 작성
});
});
cy.visit("http://localhost:3002/login");
cy.get("input[name=email]").type(Cypress.env("EMAIL"));
cy.get("button").contains("Sign in").click();
cy.location("pathname").should("equal", "/models");
cy.on("window:alert", (content) => {
expect(content).to.contains(
"Only alphabets, numbers, and underscores can be entered in the model name"
);
});
cy.get("select[name=task]")
.select("Image Classification")
.should("have.value", "image_classification");
// as 이용하여 별명으로 재사용, 파일 읽을 때 fixture 메소드 사용하면 동적 변경 불가
cy.readFile("cypress/fixtures/mobilenet_v1.h5", null).as("model");
cy.get("input[type=file]").selectFile("@model", { force: true });
cy.intercept("POST", "**/models").as("postModel"); // 별명으로 재사용
cy.wait("@postModel"); // then으로 이어 붙일 필요 없이 아래에 진행할 내용을 작성
cy.on("window:alert", (content) => {
expect(content).to.contains("Model is uploaded successfully");
});