【发布时间】:2018-09-06 12:17:05
【问题描述】:
有一个最近的需求,我需要使用 Spectron 对后端节点 js 应用程序进行测试自动化。我想知道要达到同样的要求需要哪些编程技能
【问题讨论】:
标签: testing automated-tests electron spectron
有一个最近的需求,我需要使用 Spectron 对后端节点 js 应用程序进行测试自动化。我想知道要达到同样的要求需要哪些编程技能
【问题讨论】:
标签: testing automated-tests electron spectron
在https://electronjs.org/spectron 查找 Spectron 文档
安装
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 可以与任何测试框架一起使用。我更喜欢使用摩卡咖啡。
克隆此项目以获取更多信息https://github.com/electron/spectron
【讨论】: