Testing 如何安装spectron并在其上开始编写脚本?
最近有一个需求,我需要使用spectron对后端节点js应用程序进行自动化测试。我想知道达到同样的目的所需的编程技能。请访问Spectron文档 装置Testing 如何安装spectron并在其上开始编写脚本?,testing,automated-tests,electron,spectron,Testing,Automated Tests,Electron,Spectron,最近有一个需求,我需要使用spectron对后端节点js应用程序进行自动化测试。我想知道达到同样的目的所需的编程技能。请访问Spectron文档 装置 npm install --save-dev spectron 示例测试文件如下所示 const Application = require('spectron').Application const assert = require('assert') const electronPath = require('electron') cons
npm install --save-dev spectron
示例测试文件如下所示
const Application = require('spectron').Application
const assert = require('assert')
const electronPath = require('electron')
const path = require('path')
describe('Application launch', function () {
this.timeout(10000)
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)
})
})
})
Spectron可以使用任何测试框架。我喜欢用摩卡咖啡
有关详细信息,请克隆此项目