01
Getting Started
Basic Test
Cypress runs in the browser.
cypress
describe("Home", () => {
it("loads", () => {
cy.visit("/");
cy.contains("Welcome");
});
});Interactions
Chainable commands for user interactions.
cypress
cy.get("input").type("hello");
cy.get("button").click();
cy.get(".result").should("contain", "hello");Assertions
should() for assertions.
cypress
cy.get("#count").should("have.text", "5");
cy.get("li").should("have.length", 3);
cy.url().should("include", "/dashboard");02
Features
Fixtures
Fixtures for test data.
cypress
cy.fixture("user.json").then(user => {
cy.get("input").type(user.name);
});Custom Commands
Custom commands for reusable steps.
cypress
Cypress.Commands.add("login", (email, pw) => {
cy.get("#email").type(email);
cy.get("#pw").type(pw);
cy.get("button").click();
});
cy.login("a@b.com", "secret");Was this helpful?