# Connectors

Examples of connecting commands in Cypress, for a full reference of commands, go to docs.cypress.io

#### cy.each()

To iterate over the elements of a current subject, use the `cy.each()` command.

    cy
      .get('.connectors-each-ul>li')
      .each(function($el, index, $list){
        console.log($el, index, $list)
      })

- Lara Williams
- William Grey
- Monica Pharrel

#### cy.its()

To get the properties on the current subject, use the `cy.its()` command.

    cy
      .get('.connectors-ul>li')
      // calls the 'length' property returning that value
        .its('length')
          .should('be.gt', 2)

- Chai
- Chai-jQuery
- Chai-Sinon

#### cy.invoke()

To invoke a function on a current subject, use the `cy.invoke()` command.

    cy
      .get('.connectors-div').should('be.hidden')

      // call the jquery method 'show' on the 'div.container'
      .invoke('show')
        .should('be.visible')

This is a div

#### cy.spread()

To spread an array as individual arguments to a callback function, use the `cy.spread()` command.

    var arr = ['foo', 'bar', 'baz']

    cy.wrap(arr).spread(function(foo, bar, baz){
      expect(foo).to.eq('foo')
      expect(bar).to.eq('bar')
      expect(baz).to.eq('baz')
    })

#### cy.then()

To invoke a callback function with the current subject, use the `cy.then()` command.

    cy.get(".connectors-list>li").then(function($lis){
      expect($lis).to.have.length(3)
      expect($lis.eq(0)).to.contain("Walk the dog")
      expect($lis.eq(1)).to.contain("Feed the cat")
      expect($lis.eq(2)).to.contain("Write JavaScript")
    })

- Walk the dog
- Feed the cat
- Write JavaScript