Implementing an Add to Favorite feature
Let’s investigate implementing our next feature: 'adds city to favorite list'
. Because this is a feature that is critical in the weather application, we want to make sure users can see the city being added and that the dropdown is closed.
First, we’ll start with another Cypress test:
it('adds city to favorite list', () => { cy.intercept("GET", "https://api.openweathermap.org/geo/1.0/direct?q=*", { statusCode: 200, body: searchResults, }); cy.visit('http://localhost:3000/'); cy.get('[data-testid="search-input"]').type('Melbourne'); cy.get('[data-testid="search-input"]').type('{enter}'); cy.get('[data-testid="search-results"] .search-result') .first() ...