Test Variations of a Feature in Cypress with a data-driven Test

Share this video with your friends

Send Tweet

Many applications have features that can be used with slight variations. Instead of maintaining multiple tests with nearly identical code, we can take advantage of the JavaScript runtime and use normal data structures and plain old JavaScript to test and make assertions for multiple interactions in a single test.

Hoang
Hoang
~ 6 years ago

why can't we just loop through the values of the filters array ? what's the purpose of the cy.wrap function

filters.forEach(filter => {
    cy.contains(filter.link).click()

    cy.get('.todo-list li').should('have.length', filter.expectedLength)
})
Pavel Klochkov
Pavel Klochkov
~ 5 years ago

There is the misprint in the transcription in block 03:47. In the code at line 11. You have .each(filters => { instead of .each(filter => {