abhinaba-ghosh / cypress-react-selector

:zap: cypress plugin to locate react elements by component, props and state

Home Page:https://www.cypress.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Functions react() and getReact() - infinite retrying for failed upcoming assertions

daniele-pini opened this issue · comments

Summary

The following code:

getReact('MyComponent', { options: { timeout: 1000 })).should(() => {
  expect(false).to.equal(true);
});

Will keep retrying the assertion without regard to the specified timeout

Why is this happening?

Because retries checking only happens as long as the component being looked up is not found:

return _nodes().then((value) => {
if (!value) {
if (retries < 1) {
cy.log(
getComponentNotFoundMessage(
component,
reactOpts.props,
reactOpts.state
)
);
return;
}

Once the component is found the if (!value) will skip retries checking, even if we're retrying continuously due to failed assertions.

@abhinaba-ghosh, I'm looking into this - I have a fix, just need to write a suitable test...