01
Einstieg
Einfacher Test
Cypress läuft im Browser.
cypress
describe("Home", () => {
it("loads", () => {
cy.visit("/");
cy.contains("Welcome");
});
});Interaktionen
Verkettbare Befehle für Nutzerinteraktionen.
cypress
cy.get("input").type("hello");
cy.get("button").click();
cy.get(".result").should("contain", "hello");Assertions
should() für Assertions.
cypress
cy.get("#count").should("have.text", "5");
cy.get("li").should("have.length", 3);
cy.url().should("include", "/dashboard");02
Funktionen
Fixtures
Fixtures für Testdaten.
cypress
cy.fixture("user.json").then(user => {
cy.get("input").type(user.name);
});Custom Commands
Custom Commands für wiederverwendbare Schritte.
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?