An Electron Testing Framework
An open source framework for easily writing integrations tests for your Electron app. Spectron sets up and tears down your app and allows it to be test-driven remotely with full support for the Electron APIs. Built on top of ChromeDriver and WebDriverIO.
Spectron makes the entire Chromium and Electron APIs available to your tests.
Interact with and verify the behavior of multiple windows from a single test.
# Install Spectron
$ npm install --save-dev spectron
// A simple test to verify a visible window is opened with a title
var Application = require('spectron').Application
var assert = require('assert')
var app = new Application({
path: '/Applications/MyApp.app/Contents/MacOS/MyApp'
})
app.start().then(function () {
// Check if the window is visible
return app.browserWindow.isVisible()
}).then(function (isVisible) {
// Verify the window is visible
assert.equal(isVisible, true)
}).then(function () {
// Get the window's title
return app.client.getTitle()
}).then(function (title) {
// Verify the window's title
assert.equal(title, 'My App')
}).then(function () {
// Stop the application
return app.stop()
}).catch(function (error) {
// Log any failures
console.error('Test failed', error.message)
})