assertions chained off getProps() should retry
shand-j opened this issue · 2 comments
When asserting on a prop value that is liable to change during a test, if the value has not updated when getProps() executes then any following assertion will fail.
Assertions should be retried to allow time for react to update the prop value.
cy.getReact('PlanPanel').getProps('planSelected').should('eq', 'plan1') // the selected plan is stored as the value of planSelected prop cy.get(
[data-testid=panel-button--planTwo]).click() // changes the selected plan cy.getReact('PlanPanel').getProps('planSelected').should('eq', 'plan2') // prop value should equal the new plan
The result when the test executes is intermittent failure. The addition of an arbitrary wait of half a second ensures consistent passing.
cy.getReact('PlanPanel').getProps('planSelected').should('eq', 'plan1') // the selected plan is stored as the value of planSelected prop cy.get(
[data-testid=panel-button--planTwo]).click() // changes the selected plan cy.wait(500) cy.getReact('PlanPanel').getProps('planSelected').should('eq', 'plan2') // prop value should equal the new plan
Hey, thanks for opening an issue. Could you open a pull request with a unit test that shows the problem?
Closing without reproducible example