Skip to content

Add awaiting wrapped object section to Retry-ability guide #1542

@amirrustam

Description

@amirrustam

The Retry-ability guide demonstrates assertions on DOM elements, but the concept of retrying assertions also applies to regular objects via cy.wrap. Example:

  it('waits for changed property value', () => {
    const o = { foo: 20 }

    // changes property "foo" after delay
    setTimeout(() => {
      o.foo = 42
    }, 100)

    // "expect" syntax does NOT work
    // because it is not retried!
    // expect(o).to.have.property('foo', 42)

    // wrapping an object and using "should" syntax retries
    // the assertion until the "o.foo = 42" runs and the assertion passes
    cy.wrap(o).should('have.property', 'foo', 42)
  })

🔗 Source and more examples

This ability should also be stated in this guide. We already seen a large user create work-arounds because they did not know about using cy.wrap to wait on object changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions