Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
amirrustam opened this issue Apr 2, 2019 · 1 comment

Comments

3 participants
@amirrustam
Copy link
Member

commented Apr 2, 2019

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.

@amirrustam amirrustam self-assigned this Apr 2, 2019

@bahmutov

This comment has been minimized.

Copy link
Collaborator

commented Apr 2, 2019

also this blog post that talks about Redux store might point it out explicitly https://github.com/cypress-io/cypress-example-recipes#blogs "Testing Redux Store"

AND it needs link to the actual blog post https://www.cypress.io/blog/2018/11/14/testing-redux-store/ !! And we need to call attention to automatic retrying of cy.window().its('STORE_NAME').should('exist')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.