describe('Test cy.siblings() and cy.closest()', () => {
beforeEach(() => {
cy.visit('https://example.cypress.io/commands/traversal')
})
it('finds siblings and closest parent', () => {
// Find the first list item and click it
cy.get('.traversal-list > li').first().click()
// From the first list item, get its sibling list items
cy.get('.traversal-list > li').first()
.siblings('li')
.should('have.length.greaterThan', 0)
// From the first list item, find the closest ul parent
cy.get('.traversal-list > li').first()
.closest('ul')
.should('have.class', 'traversal-list')
})
})