Skip to content

Proposal: .pipe command that is essentially a retryable .then #1548

@NicholasBoll

Description

@NicholasBoll

Proposal: Command that is essentially a retryable .then

Example:

const getTable = id => cy.get(`[data-testid=${id}`)
const getColumnNames = $el => Array.from($el.find('[role=columnheader]')).map(el => el.innerText)

getTable('identifier')
  .then(getColumnNames) // The `should` doesn't cause this to re-evaluate
  .should('deep.equal', ['Column One', 'Column Two'])

The getTable will get an element given a test id and getColumnNames will get the text contents of a table's column headers. If the table's column headers aren't statically known (maybe column order is a user preference), the assertion immediately fails.

I don't think we want .then to retry. I think it is good that .then has strong guarantees that it will only be run once. It just makes composition of functions not quite fit.

There could be another command that does re-run if there is an assertion:

getTable('identifier')
  .pipe(getColumnNames) // The `should` would cause re-evaluation
  .should('deep.equal', ['Column One', 'Column Two'])

Metadata

Metadata

Assignees

No one assigned

    Labels

    pkg/driverThis is due to an issue in the packages/driver directorytype: featureNew feature that does not currently exist

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions