node.jselectronmocha.jsspectron

unknown error: Chrome failed to start: exited abnormally when trying to test electron spectron with mocha


i'm trying to test electron spectron testing. my project is very simple, just clone an electron quick start repo then write code to spec.js as written from the readme file from electron-userland/spectron

but when i run npm test, i face this error:

$ npm test

> electron-quick-start@1.0.0 test /media/dna/Data D/koding/electron-example/testing-spectron
> mocha



  Application launch
    1) "before each" hook for "shows an initial window"


  0 passing (809ms)
  1 failing

  1) Application launch
       "before each" hook for "shows an initial window":
     Error: Failed to create session.
unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /media/dna/Data D/koding/electron-example/testing-spectron/node_modules/spectron/lib/launcher.js is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
      at startWebDriverSession (node_modules/webdriver/build/utils.js:45:11)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

previously i've trying to reinstall mocha and spectron, but it's return the same result.
my devDependencies:

...
  "devDependencies": {
    "electron": "^10.1.2",
    "mocha": "^8.1.3",
    "spectron": "^11.1.0"
  }
...

my os info:

Distributor ID: LinuxMint
Description:    Linux Mint 19 Tara
Release:    19
Codename:   tara

i'm using nodejs v12.18.4

you can clone my electron testing project here: electron-example


Solution

  • i've downgrade my electron version to 9.3.1 and now my project working normally. You can find specific information about electron and spectron version that can support each other from electron-userland/spectron