mocha.js - 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,请确保它已解决。
此外,我还看到多个黑色进程发送垃圾邮件,我无法捕捉应用程序窗口焦点。
感谢帮助!
谢谢
解决方案
推荐阅读
- python - 使用 date_time 对 pandas 进行 rows_manipulation,数据时间为 0-30 小时
- r - 如何使用 R 的 purrr::map 将多个 csv 文件保存在不同的文件夹中
- javascript - 如何将我的输入范围值设置为图像序列帧增量号。在javascript中?
- osgi - CLI 属性从 Boolean 更改为 String
- bash - 如何打印 git repo 中每个子文件夹的最新提交时间?
- wordpress - 如何删除 .htaccess 中的重定向
- typescript - 如何从计算属性名称的函数参数中获取文字类型?
- firebase - 使用firebase使用电话号码进行登录身份验证
- c# - 放弃等待的任务,它们是 GarbageCollected 吗?
- mysql - mysql:我没有更新触发器中定义触发器的表,但我得到了类似的错误