Cleaning Up After the Tests
Learn how to clean up after running tests with Cypress.
We'll cover the following...
In the following two tests, we insert a meetup into the database using our custom task and then visit the URL matching the slug to assert that it exists. Try to guess the result of this test and click the “Run” button to see what happens.
describe("Meetup detail page", () => { it("Should exist when it is in database", () => { cy.task("seed:events", [ { id: 1, name: "Test Meetup", slug: "test-meetup", description: "", location: "Online", dateTime: new Date(2030, 0, 1), }, ]); cy.visit("/test-meetup"); }); it("Should exist also when it is in database", () => { cy.task("seed:events", [ { id: 1, name: "Test Meetup 2", slug: "test-meetup-2", description: "", location: "Online", dateTime: new Date(2030, 0, 1), }, ]); cy.visit("/test-meetup-2"); }); }); export {};
Cypress tests
Note: Our first test passes, but the second one fails with ...