2

我正在尝试测试电子光谱测试。我的项目非常简单,只需克隆一个电子快速启动 repo,然后将代码写入 spec.js,就像从electron-userland/spectron的自述文件中写入的那样

但是当我运行 npm test 时,我遇到了这个错误:

$ 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)

以前我试图重新安装 mocha 和 spectron,但它返回相同的结果。
我的开发依赖项:

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

我的操作系统信息:

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

我正在使用 nodejs v12.18.4

你可以在这里克隆我的电子测试项目:电子示例

4

1 回答 1

2

我已将电子版本降级到 9.3.1,现在我的项目工作正常。您可以从electron-userland/spectron找到有关可以相互支持的电子和光谱版本的具体信息

于 2020-09-17T04:59:24.880 回答