Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Using cy.react after updating the state does not find the updated component #381

Closed
bahmutov opened this issue Aug 12, 2020 · 2 comments
Closed
Assignees
Labels
3rd party 📬 Issue caused by an external library bug

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Aug 12, 2020

Test cypress/component/advanced/react-book-example/src/components/ProductsList.spec.js

Using https://github.com/abhinaba-ghosh/cypress-react-selector

it('finds components by props and state', () => {
  // by clicking on the Order button we change the
  // internal state of that component
  cy.contains('.product', 'First item')
    .find('button.order')
    .click()
    .wait(1000)

  // the component is there for sure, since the DOM has updated
  cy.contains('.product', '1')
    .find('.name')
    .should('have.text', 'First item')

  // now find that component using the state value
  // DOES NOT WORK FOR SOME REASON
  cy.react('AProduct', null, { orderCount: 1 })
    .should('not.be.empty')
    .find('.name')
    .should('have.text', 'First item')
})

The DOM is there, but the cy.react does not find the component

Screen Shot 2020-08-12 at 11 14 47 AM

@abhinaba-ghosh
Copy link
Contributor

It found out, after the state changes, react-selector loose track on the react root. It is rectified now.

Changes are available in V2.0.1
Breaking changes introduced.
Raised PR: #386

@bahmutov
Copy link
Contributor Author

bahmutov commented Sep 8, 2020

works

@bahmutov bahmutov closed this as completed Sep 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd party 📬 Issue caused by an external library bug
Projects
None yet
Development

No branches or pull requests

3 participants