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

How to call the function inside of a component?

vikasm98 opened this issue · comments

I am getting the component when I use

cy.getReact('BasicTray').then((comp) => {
      cy.log('comp', comp)
})

and in the logs I can see the following output as shown in the image
Screenshot 2023-05-17 at 8 48 26 PM

but I am not able to get the function exists inside of that component.
I use this code to get the function of that component
cy.getReact('BasicTray').invoke('toggleMic')

I am getting this fllowing error
Screenshot 2023-05-17 at 8 52 24 PM

i am also getting the same error when i want to get the variable inside of that component
is there a way to get the function and call the function inside cypress end to end testing?

This is similar you would ask - how users by visiting a website could invoke some random react component function visible on the page.

Looks like you need to take a look at unit tests instead of e2e.
E2E tests should test users' flow and interactions.