1

There is a Cypress bug, that every ~100 tests cy.visit() does not load the page and the test fails after 60s of waiting. Cypress support can't help, because they want a reliable way to reproduce it, and obviously I can't give it to them in this case. I wanted to do this: call .visit() and give it a timeout of 15s, if it times out, call the command again or retry the test. I know there is a cypress-plugin-retries library, but I don't think I can retry based only on one command timing out, at least I didn't find a way to do that.

Anyone has any ideas on how could I handle it?

AciD
  • 113
  • 3
  • 8
  • We have the same issue, I logged https://github.com/cypress-io/cypress/issues/2938. `cypress-plugin-retries` made this a non-issue. It doesn't work for each command, but will retry the entire test which accomplishes the same thing for us. – Brendan Mar 03 '20 at 14:44
  • I saw that as well, but I really don't want to create retries for all of our tests. In it's current form the cypress tests are really stable, I don't want to end up with a bunch of flaky tests just because the retry is there. – AciD Mar 03 '20 at 15:24

2 Answers2

0

Maybe you could use wait until instead?

voy
  • 696
  • 7
  • 14
  • Someone suggested that as well, but I can't see the application here :/ that cy.visit would still time out and crash the whole test, right? – AciD Mar 03 '20 at 15:19
  • It works, see this answer [cypress - do action until element shows on screen](https://stackoverflow.com/a/60446878/12697177) which gives a run-through. Essentially the wrapping function ensures the first fail does not stop the test. –  Mar 04 '20 at 01:29
  • Oh, Thank you Marion for the link, really helpful, I'll check it out! – AciD Mar 04 '20 at 09:09
  • I feel like it's ALMOST it, but I need some alternative for cy.visit() that does not include assertion, so the test won't fail. They are mentioning the exposed cypress query, but I don't see anything for the cy.visit : / – AciD Mar 04 '20 at 09:37
  • @AciD but how you will know that the url you want to visit is in fact visited by cypress? :P This test fails for a reason. Is this the issue you are speaking of: https://github.com/cypress-io/cypress/issues/2938 ? – voy Mar 04 '20 at 09:40
  • Yes, that's exactly it. I know it will fail, because cypress errors on 'the page did not fire its 'load' event within 60 seconds. It doesn't fail because it didn't find something. – AciD Mar 04 '20 at 09:46
  • I'm the author of `cy.waitUntil`, I've just left a comment on the issue and I reply here too: unfortunately my waitUntil plugin can't be useful in this case because there are no "manual" alternatives to the `cy.visit` command – NoriSte Mar 05 '20 at 06:52
  • @NoriSte Understood. Thank you for the reply, though! – AciD Mar 05 '20 at 08:57
0

You can try retry : https://docs.cypress.io/guides/guides/test-retries.html#How-It-Works with a timeout

Nevertheless, all the it 'control of the loading' will be test again ,it might not be a good idea to put it inside a beforeeach

  it('Controls of the loading  ',{retries: {
    runMode: 2,
    openMode: 2
  },timeout :16000 }, () => {
//your test there such as 
cy.visit('/localhost:3033');
  });

Nevertheless, all the it 'control of the loading' will be test again ,it might not be a good idea to put it inside a beforeEach .

uromys
  • 1
  • 1