1

I am using Electron to write a desktop application. I want to use Spectron and Mocha because they seem to be the biggest and most supported things out there for testing electron. I am in Windows 10.

using the boiler plate project here :

https://github.com/florin05/electron-spectron-example

The testbed works using 'npm install' then 'npm test'.

then I cleared out the node_modules folder and did it again, after I only changed electron and spectron to their newest versions. Spectron to 12.0.0 and electron to 10.0.0(per spectron's minor version matching requirement).

Now the test bed gives me the following error

 1) Sample Test
       "before each" hook for "opens a window":
     javascript error: javascript error: Cannot convert undefined or null to object
  (Session info: chrome=85.0.4183.84)
      at Object.getErrorFromResponseBody (node_modules\webdriver\build\utils.js:94:12)
      at WebDriverRequest._request (node_modules\webdriver\build\request.js:133:31)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at async Browser.wrapCommandFn (node_modules\@wdio\utils\build\shim.js:58:29)
      at async Browser.wrapCommandFn (node_modules\@wdio\utils\build\shim.js:58:29)
      at async Object.startApp (test\hooks.js:13:17)
      at async Context.<anonymous> (test\search.js:9:11)

This seems like the simplest possible test of electron and I cannot figure out what I am doing incorrectly. Are there any Electron testing experts out there that would like to tell me why this does not work? I am fairly new to Node and web dev, perhaps I've overlooked something implicit.

Jody Sowald
  • 332
  • 1
  • 14
  • Did you figure out the issue? – Duke79 Nov 07 '20 at 05:39
  • @Duke79 The short answer that i have found by piecing things together is that mocha was not the issue, spectron's chromedriver doesn't seem to work in the newest version. Instead i am piecing together ui tests using mocha node, but to get mocha to work in the renderer has been rough, i know it can be done because of the Electron-Mocha project, so I'll be piecing that together into my project. I feel as though i am missing information about what different testing suites are as this all seems far too complicated to be normal but are supposedly very popular – Jody Sowald Nov 08 '20 at 06:43
  • So, not resolved yet ?! :( – Duke79 Nov 09 '20 at 11:45
  • @Duke79 I did figure it out yesterday! Well I figured out how to get mocha node working for dom tests, i cut Spectron out completely. I realized that this fantastic project https://github.com/jprichardson/electron-mocha does exactly what i wanted to make itself work. its built on mocha to run tests in an electron window for easy debugging. It is not made for using mocha to test an electron app, I adapted the code in the renderer and lib folder to get mocha renderer tests working in our app – Jody Sowald Nov 11 '20 at 13:53

0 Answers0