问题描述
我正在使用Spectron测试一个简单的电子应用程序。以下是我的test.js,它具有一个可以单击元素的测试用例。
const Application = require('spectron').Application;
const assert = require('assert');
const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
const path = require('path');
describe('Application launch',function () {
this.timeout(30000);
beforeEach(function () {
this.app = new Application({
path: electronPath,args: [path.join(__dirname,'..')]
});
return this.app.start();
});
afterEach(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop();
}
});
it('shows an initial window',function () {
return this.app.client.getwindowCount().then(function (count) {
assert.equal(count,1);
});
});
it('Navigate to settings',async function () {
return this.app.client.click('#settings').then(function (data) {
console.log(data);
});
});
});
当我运行mocha时,输出如下。
√ shows an initial window
1) Navigate to settings
1 passing (45s)
1 failing
1) Application launch
Navigate to settings:
TypeError: this.app.client.click is not a function
at Context.<anonymous> (test\test.js:30:28)
at process._tickCallback (internal/process/next_tick.js:68:7)
npm ERR! Test Failed. See above for more details.
我是摩卡测试的新手,无法找到解决方案。 预先感谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)