cypress-react-selector icon indicating copy to clipboard operation
cypress-react-selector copied to clipboard

Cannot find component with props, despite showing in browser console

Open joetidee opened this issue 5 years ago • 11 comments
trafficstars

I have this code: Screen Shot 2020-11-15 at 19 18 31

but it produces this error: Screen Shot 2020-11-15 at 19 18 40

even though the Chrome Dev Tools Component tab show this: Screen Shot 2020-11-15 at 19 18 17

joetidee avatar Nov 15 '20 19:11 joetidee

This is intersting. Can you check if that component really exists or not.

cy.waitForReact();
cy.get(..).click()
cy.react('component name', {props:{your prop}}).should('exist');
cy.getReact(..).getProps(..).should('eq', true);

abhinaba-ghosh avatar Nov 19 '20 05:11 abhinaba-ghosh

This is what I see when I try the above: Screen Shot 2020-11-21 at 11 43 10

joetidee avatar Nov 21 '20 11:11 joetidee

it's react, not getReact for the exist command:

cy.react('component name', {props:{your prop}}).should('exist');

abhinaba-ghosh avatar Nov 21 '20 13:11 abhinaba-ghosh

hey, i'm also having this issue.

This is what I'm seeing in react dev tools. image

This is the code I'm using to look for the component.

cy.waitForReact(); cy.react('DisplayLeadDetails').should('exist');

This is the error I'm seeing. image

I did notice that if I were to look for say the ba component you see in the screenshot, it does pick it up correctly. Wonder if that can help debug this issue.

mdn021 avatar Dec 02 '20 20:12 mdn021

Hi, can you guys try with the latest version v2.2.2 and check if still happening.

abhinaba-ghosh avatar Dec 15 '20 06:12 abhinaba-ghosh

Still getting the same issue, unfortunately.

mdn021 avatar Dec 15 '20 15:12 mdn021

I'm seeing this issue in a component test where each test mounts a new component tree. The first test works and all other tests work, with .only, but if I allow them all to run, getReact and react queries fail.

This is on cypress 7.2.0.

sovanyio avatar May 07 '21 20:05 sovanyio

@sovanyio Thanks for bringing the issue under the light. Can you confirm if the window gets reloaded every time you load a component? If so, you need to call waitForReact each time. I am interested in the codebase, can you share any repository where I can re-produce the bug?

abhinaba-ghosh avatar May 08 '21 06:05 abhinaba-ghosh

Just want to drop a note that this hasn't fell off of my radar, life got unexpectedly busy this week. I will try to get something up next week.

sovanyio avatar May 14 '21 15:05 sovanyio

i think it is because of forwardref type react components i think this plugin does not support them cz i also tried fetching them but it's not working. i also tried cy.react as well Image 5

rmrao12 avatar May 25 '21 08:05 rmrao12

I'm seeing this issue in a component test where each test mounts a new component tree. The first test works and all other tests work, with .only, but if I allow them all to run, getReact and react queries fail.

This is on cypress 7.2.0.

I have opened this issue, specific to component testing: https://github.com/abhinaba-ghosh/cypress-react-selector/issues/235

francisu avatar Sep 21 '21 19:09 francisu