electron-userland / spectron

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

A guide to fixing "Why won't my tests run on Windows?" #337

Open imlucas opened 6 years ago

imlucas commented 6 years ago

There are several issues open around spectron on windows oddities; chromedriver timing out, app failed to initialize and more (examples below). Having spent the past week digging around and fixing this for MongoDB Compass's testing, I found and fixed an issue I hadn't seen reported elsewhere: The command line is too long. buried in the chromedriver logs causing app.start() to hang or fail with various timeout errors. The full details are in mongodb-js/hadron-spectron#3 but the tldr is:

  1. Check the electron ➡️ spectron version map!
  2. Enable and carefully study the chromedriver logs, specifically look for ERROR, SEVERE, WARNING, command line is too long
  3. Be careful when passing env: process.env to the Application constructor... this is what was causing the silent, fatal command line is too long for me
  4. This is as far as I needed to go. If anyone else has other fixes, I'd love to hear in comments for the sake of my future, stuck-debugging self 😺

@MarshallOfSound I'd send a PR for this but wasn't quite sure where it should go. README perhaps? I've just noticed a ton of these "Won't work on Windows issues" and wanted to help the reporters get unblocked.

219 #144 probably others?

lottec commented 5 years ago

To add to this, I just spent so much time trying to debug why my, while working fine on OSX, on Windows my spectron tests were timing out on the beforeEach hook (where I was calling app.start() on the spectron Application instance). Turns out it works just fine with mocha but not with electron-mocha, which we're using for unit tests...

imlucas commented 5 years ago

@lottec hmm. which version of electron-mocha are you on? 6.0.x works for me.

imlucas commented 5 years ago

I have this all working locally... But in our CI running under cygwin... no such luck...