Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Receipt form test
describe("New recipe form", () => {
const apiUrl = "";
beforeEach(() => {
// Start server before each test to allow stubs
it("adds new recipe", () => {
// Define stub for our request
method: "POST",
url: apiUrl,
response: {}
}).as("postAddRecipe"); // Visit page with form (root in our case)
cy.visit("/"); // Fill in form values and submit it
cy.get('input[name="name"]').type("Ackee pasta with salmon");
cy.get("textarea").type("Boil water, add pasta and cook salmon");
cy.get('button[type="submit"]').click(); // Wait for request to resolve
cy.wait("@postAddRecipe"); // Test success label has been displayed
cy.get("#successLabel").contains("Recipe was successfully created!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.