Cypress E2E testing patterns -- selectors, cy.intercept, cy.session, cy.clock, custom commands, test isolation, and anti-patterns
98
99%
Does it follow best practices?
Impact
97%
1.25xAverage score across 4 eval scenarios
Passed
No known issues
An e-commerce web application needs E2E tests for its shopping cart and checkout flow. Write Cypress tests for adding products to the cart, updating quantities, and completing checkout.
The app runs on http://localhost:3000 with these pages:
/products -- product listing with "Add to cart" buttons on each product card/cart -- cart page showing items, quantities, subtotals, and a "Proceed to checkout" button/checkout -- checkout form with shipping address fields, payment section, and "Place order" button/orders/:id -- order confirmation pageThe app has these API endpoints:
GET /api/products -- returns product listPOST /api/cart/items -- adds item to cartPATCH /api/cart/items/:id -- updates item quantityDELETE /api/cart/items/:id -- removes item from cartGET /api/cart -- returns current cart contentsPOST /api/orders -- creates an order from the cartProduce:
cypress.config.ts -- Cypress configurationcypress/e2e/cart.cy.ts -- tests for cart operations (add, update quantity, remove)cypress/e2e/checkout.cy.ts -- tests for the checkout flow and form validationcypress/support/commands.ts -- any reusable test helperscypress/fixtures/products.json -- fixture data for product API responsespackage.json -- with cypress dependency listedYou may create additional files for good test organization.