electron-userland / spectron

DEPRECATED: 🔎 Test Electron apps using ChromeDriver
http://electronjs.org/spectron
MIT License
1.68k stars 229 forks source link

Spectron hangs #272

Open manu-st opened 6 years ago

manu-st commented 6 years ago

We have been using Spectron to test our electron app with some success, however we encounter those situation where the test suite hangs due to electron crashing.

Here are some info on our setup. We use TypeScript and jest to run Spectron on Windows 10. Jest is ran with the --runInBand option.

Although the outcome was not always consistent we noticed that most of the time when Spectron hangs, there is only one electron.exe left with launcher.exe and chromedriver.exe as parent process. Putting traces in both our test scripts in jest and in the application being debugged, we can see that the crash of electron trigger some failures in our expect clauses which causes us to call app.stop () to terminate the test. However this usually fails with an exception that there is no more windows or chrome not reachable.

At this point, it either continues onto the next tests but hangs at the end, or it hangs right away.

Although we understand that electron crashing is the cause of spectron hanging, it would be best if it was not hanging. Any advice on how to prevent spectron from hanging and report a proper error message?

Thanks!

manu-st commented 6 years ago

Some more feedback. We noticed that somehow wen it hangs, it does not completely hangs, it just wait exactly 5 minutes before continuing onto the next test. It is not clear whose timeout it is though as we set the all the jasmine and spectron timeouts to something less than a minute. But it is on the clock, every five minutes it will abandon what it is doing and fire the next test.

But that was not enough, there was still the electron's main process. So to avoid having to wait a long time for all the timeouts, we detect at the beginning of each test if the electron's renderer process is still around and if not, we simply skip the test. This is not a solution but enables to have short turnaround cycle when we have a situation where electron crashes.