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

not able to find react component due to forwardref type of components #192

Open
rmrao12 opened this issue May 25, 2021 · 5 comments
Open
Labels
help wanted Extra attention is needed

Comments

@rmrao12
Copy link

rmrao12 commented May 25, 2021

hi i am trying to test this website https://www.retrospected.com/
but i am unable to do it because their react components are of forwardref type and that is why this cypress is giving an error. is their any way to access these kind of components because i need to test this site using react components props etc i am attaching two pictures one with the error and one with the website type of components please check and tell me the solution.
my test case type is
describe('It should validate cypress react selector', () => {
before(() => {
cy.visit('https://www.retrospected.com/');
cy.waitForReact(5000);
});

it('it should login', () => {

cy.react('Anonymous', { props: { children: 'Login' } }).click();
hkhk
Image 5

});

});

@smerling-coremedia
Copy link

I have the same problem atm. The thing is, property "children" is not really a string. If you use cy.getReact(...).getProps() you'll see, it is an array of all children and the are objects themselves. I think it is a problem when using Material UI like your example website does and also my project.

@smerling-coremedia
Copy link

see: #134

@abhinaba-ghosh abhinaba-ghosh added the help wanted Extra attention is needed label Jul 6, 2021
@irfancankalelikargo
Copy link

Still an issue

@jime2003
Copy link

I just started using Cypress reach selector and I have exact same issue. @abhinaba-ghosh - are we going to fix the issue or any other work around?

@Shaegi
Copy link

Shaegi commented Feb 8, 2023

You can add a displayName to your component to find them

const Foo = fowardRef((props, ref) => <div ref={ref} /> ) 

Foo.displayName = 'Foo' 

export { Foo }
cy.react('Foo').should('exist')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants