https://cypress.io logo
Cypress CLI hanging when clicking any element
# i-need-help
s
I thought I'd fixed this after reading about
element.trigger('click')
but it was a mistake. We're using storybook to display the page. I'm using the 'full screen' mode so it's not iframe related. Very simple test
Copy code
cy.get('element').click()
cy.url().should('include', '/stores')
I've tried using
.wait(5000).click()
-
focus().click()
-
click({force:true})
and variations with `trigger('click')`too If I use the cypress ui - the test closes as soon as the click event is finished, it won't wait or anything, so I can't debug it. If I use the CLI in any way, the test hangs on the
click()
and doesn't do anything. If I use the
trigger('click')
the test runs but fails because the url doesn't change. Which makes me think the click isn't working there, either. Any ideas anyone? I've been trying this for a few hours now.
I've read through this too - and tried clicking to the right etc. but it's not helped. https://runebook.dev/en/docs/cypress/api/commands/click
ah ok - it's crashing the cypress app. I just added --headed and can see the element gets clicked...but the app goes white
but using cypress open doesn't crash when running the test
w
could you confirm Cypress version? If using 12 or over, I would be interested if this reproduces with something below 12, like 11.2.0? 12 introduced some changes with commands, it would be interested to know if the same crash happens before/after.
s
Yeah it's 12 - first time using cypress so it was a fresh install from a few weeks ago.
I tried it with version 11.2.0 and also happens on that too. We've got the component setup to use
vueRouter from 'storybook-vue3-router'
. So when we manually click the element in storybook, it basically goes back to root/home.
w
Possibly that router has some code to bust out of the iframe and take over window.top, which is where cypress is running. So this is an end to end test that visits a running instance of storybook to test a component, is that right? Have you considered writing component tests for this situation? Or is this already a component test?
s
Correct - we are doing component tests using mount with test-utils...the project used to require a java ui test because we used to use a nuxt app...but now we're making the components that another team are using. So storybook is the only ui and I wanted to get a bit of cypress experience 🙂
looks like we're removing the router, I've seen from a PR
3 Views