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

Unresolved API calls cause Electron to fail all subsequent tests #1055

Closed
QualityADHD opened this issue Dec 11, 2017 · 6 comments
Closed

Unresolved API calls cause Electron to fail all subsequent tests #1055

QualityADHD opened this issue Dec 11, 2017 · 6 comments

Comments

@QualityADHD
Copy link

  • Operating System: OSX 10.13.1
  • Cypress Version: 1.1.4
  • Browser Version: Chrome 63

Is this a Feature or Bug?

Bug

Current behavior:

Unresolved API calls cause Electron to timeout each subsequent test in the suite. This happens when using the Electron GUI or the CLI. Chrome handles this error gracefully and allows the tests to pass.

In addition, the failure causes the log on the left-hand side of the GUI to disappear, and you have to completely kill Cypress in order for new tests to run.

Desired behavior:

All unresolved API calls should be cancelled before a new test runs. Ideally, the behavior could mimic what Chrome 63 does.

How to reproduce:

Write a test where the API will not resolve then put that test in the middle of a suite. You will see that all tests prior will pass, but any test after will fail.

Additional Info (images, stack traces, etc)

Electron, showing the calls that will timeout:

screen shot 2017-12-11 at 1 40 15 pm

Chrome, showing the aborted calls:

screen shot 2017-12-11 at 1 39 29 pm

Failure showing the log missing:

screen shot 2017-12-11 at 2 04 53 pm

@brian-mann
Copy link
Member

This is unfortunately a known issue and its documented in depth here:

#686

There is not really an elegant solution around this - we in fact used to abort current running XHR's specifically for this purpose, but it actually caused other issues. Because Cypress runs async things between tests, it was also possible in that brief moment for your app to make another XHR, which would then demonstrate the same problems as you're describing.

The only real solution for this is doing what is described in that issue.

Today, if you wanted to "work around this" you would have to visit a "blank page" in an afterEach handler, which is really awful and ugly. Essentially this would "wipe out" your application at the end of the test which forces it to be completely torn down. There might be another easier way but I can't think of one.

@QualityADHD
Copy link
Author

Thank you for the quick reply! I figured that you guys might have ran into this before, so it's good to know that it's been explored. The discussion in the other thread makes sense; in the meantime, I will do the ugly workaround since this is mission-critical for us.

@brian-mann
Copy link
Member

Some other ideas - if your application has a "killswitch" you could directly call that from Cypress itself as long as your app exposed this globally...

afterEach(() => {
  cy.window().its('App').invoke('kill')
})

You could also likely force the app to visit about:blank... I don't think `cy.visit('about:blank') works but you could probably do this..

afterEach(() => {
  cy.window().then((win) => {
    win.location.href = 'about:blank'
  })
})

One final suggestion - conditionally run the afterEach with an environment variable, so that you can disable these when you're working on a single test in the GUI, but enable it when you're doing a complete run.

@QualityADHD
Copy link
Author

Awesome tips, thank you very much!

Sadly, no kill switch...looks like I'll have to try the 'about:blank' idea. Luckily, this issue is only happening with 2 tests, so it should not be too invasive. I'll definitely put it into an env variable, would be nice to turn off as needed.

@jennifer-shehane
Copy link
Member

Video of test run: https://files.gitter.im/cypress-io/cypress/uJe7/0zezc.mp4

The thing that troubled me the most was the command log disappearing halfway through the video recording.

@Gayathri-Kesavakannan
Copy link

Hi , I am facing this issue in electron only in headed mode. Workaround seems to flaky as some time blank page as browser waits for about:blank page to load.
Any other workarounds ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants