Spectron测试失败的原因很奇怪

时间:2020-08-17 14:54:42

标签: mocha spectron

Spectron ***的新用户

我正在尝试编写一个简单的测试,以使用Spectron检查应用程序窗口计数。下面是代码。

const Application = require('spectron').Application
const assert = require('assert')
const electronPath = require('electron')
const path = require('path')
const { doesNotReject } = require('assert')
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');


 describe('Launch app', function() {

let app =  new Application({
  
  path: 'C:/Users/ts/Downloads/file.exe',
  chromeDriverArgs: ["--disable-extensions"],
  env: {
    SPECTRON: true,
    ELECTRON_ENABLE_LOGGING: true,
    ELECTRON_ENABLE_STACK_DUMPING: true
  },
  connectionRetryCount:0
});

beforeEach(async () => { 
  this.timeout(5000); 
  await app.start();
});

it('Shows an initial window', async () => {
  await app.client.waitUntilWindowLoaded();
  await app.browserWindow.focus();
  await app.browserWindow.setAlwaysOnTop(true);
  await app.client.getWindowCount();
    assert.equal(count, 1);
});

after(async () => {
     await app.stop();
  });

})

不幸的是,测试失败的原因很奇怪:

错误:超时超过2000毫秒。对于异步测试和挂钩,请确保调用了“ done()”;如果返回了Promise,请确保它可以解决。

此外,我还看到了多个黑色进程垃圾邮件,并且无法捕获应用程序窗口焦点。

感谢帮助!

谢谢

0 个答案:

没有答案
相关问题