Spectron - javascript ошибка: экран требует удаленного, который не включен - PullRequest
0 голосов
/ 12 января 2020

Я пытаюсь использовать Spectron для автоматизации веб-приложения в приложении Electron. Для этого я создал следующий скрипт basi c, но он не работает со следующей ошибкой при запуске теста. Ценю, если кто-то может помочь. Спасибо!

сообщение об ошибке

  test-electron
    1) "before all" hook for "open electron"

  0 passing (4s)
  1 failing

  1) test-electron
       "before all" hook for "open electron":
     javascript error: screen requires remote, which is not enabled
  Error: An error occurred while executing user supplied JavaScript.
      at execute(<Function>, "require") - C:\git\applications\test-shell-app\tests\node_modules\spectron\lib\api.js:72:26

пакет. json

{
  "name": "spectron-test",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha test.js --watch"
  },
  "author": "testers",
  "license": "ISC",
  "devDependencies": {
    "chai": "^4.2.0",
    "chai-as-promised": "^7.1.1",
    "electron": "5.0.8",
    "electron-chromedriver": "^1.7.1",
    "mocha": "^7.0.0",
    "spectron": "7.0.0"
  }
}

спектрон-помощник. js Я создал этот помощник для предоставления экземпляра спектра для тестов.

const Application = require('spectron').Application;
const electronPath = require('electron');
const path = require('path');

function initialiseSpectron() {
  const appPath = path.join(__dirname, '../dist/electron/main.js');
  return new Application({
    path: electronPath,
    args: [appPath],
    startTimeout: 60000,
    chromeDriverLogPath: '../chromedriverlog.txt',
  });
}

module.exports.initialiseSpectron = initialiseSpectron;

тест. js Мой тест с крючками до и после

const testhelper = require('./spectron-helper');
const app = testhelper.initialiseSpectron();
const chaiAsPromised = require('chai-as-promised');
const chai = require('chai');
chai.should();
chai.use(chaiAsPromised);

describe('test-electron', function () {

    before(function () {
        this.timeout(60000);
        chaiAsPromised.transferPromiseness = app.transferPromiseness;
        return app.start();
    });

    after(function () {
        if (app && app.isRunning()) {
            return app.stop();
        }
    });

    it('open electron', function () {
        return app.browserWindow.client
            .waitUntilWindowLoaded()
            .getWindowCount()
            .should.eventually.equal(1);
    });
});
...