© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
J. QiuTest-Driven Development with Reacthttps://doi.org/10.1007/978-1-4842-6972-5_7

7. Searching by Keyword

Juntao Qiu1  
(1)
Burwood East, 3151, Victoria, Australia
 

Our third feature will allow a user to search for a book by its name. This is useful when the book list becomes very long – it can be hard for a user to find what they are looking for when content is more than one screen or page.

Acceptance Test

As previously, we start by writing an acceptance test :
  it('Searches for a title', () => {
    cy.visit('http://localhost:3000/');
    cy.get('div.book-item').should('have.length', 4);
    cy.get('[data-test="search"] input').type('design');
    cy.get('div.book-item').should('have.length', ...

Get Test-Driven Development with React: Apply Test-Driven Development in Your Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.