I have a textbox. When user types something I will hit api and insert a list of items <ul>
into DOM. On textbox blur, I will remove <ul>
from DOM.
it('Category search', () => {
cy.intercept('GET', `http://localhost:3000/categories/query**`, {fixture: 'categories.json'})
cy.visit(`http://localhost:3000/items`)
cy.clock()
cy.tick(2000)
cy.get('#category').click().type('o')
cy.get('ul[class*="category-list"]').its('length').should('eq', 10)
});
Cypress test can't find cy.get('ul[class*="category-list"]')
. Because, when cypress reaches to this line my textbox loses its focus. So, ul tag removed automatically.
Can anyone please help? Thanks in advance.