01
시작하기
기본 테스트
Cypress는 브라우저에서 실행됩니다.
cypress
describe("Home", () => {
it("loads", () => {
cy.visit("/");
cy.contains("Welcome");
});
});인터랙션
사용자 인터랙션을 위한 체이닝 가능한 명령어를 제공합니다.
cypress
cy.get("input").type("hello");
cy.get("button").click();
cy.get(".result").should("contain", "hello");단언(Assertion)
단언에는 should()를 사용합니다.
cypress
cy.get("#count").should("have.text", "5");
cy.get("li").should("have.length", 3);
cy.url().should("include", "/dashboard");02
주요 기능
픽스처(Fixture)
테스트 데이터로 사용할 픽스처를 제공합니다.
cypress
cy.fixture("user.json").then(user => {
cy.get("input").type(user.name);
});커스텀 커맨드
재사용 가능한 단계를 커스텀 커맨드로 만들 수 있습니다.
cypress
Cypress.Commands.add("login", (email, pw) => {
cy.get("#email").type(email);
cy.get("#pw").type(pw);
cy.get("button").click();
});
cy.login("[email protected]", "secret");Was this helpful?