Files
cypress/docs/source/api/commands/spread.md
T
2017-05-19 12:01:36 -04:00

875 B

title, comments, description
title comments description
spread true

The spread command allows an expression to be expanded in places where multiple arguments are expected. Similar to cy.then, but always expects an array as it's subject.

Returns the value of the spread
Timeout cannot timeout

cy.spread( fn )

Expand an array of arguments.

Usage

Expand the array of aliased routes

cy
  .server()
  .route(/users/).as("getUsers")
  .route(/activities/).as("getActivities")
  .route(/comments/).as("getComments")
  .wait(["@getUsers", "@getActivities", "@getComments"])
  .spread(function(getUsers, getActivities, getComments){
    // each XHR is now an individual argument
  })

Related