Spectron icon

Spectron logo

An Electron Testing Framework

Test your app

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.

CI Ready

Tests can run on continuous integration services such as Travis and AppVeyor.

Full API

Spectron makes the entire Chromium and Electron APIs available to your tests.

Multi Window

Interact with and verify the behavior of multiple windows from a single test.

Promises

Easily chain together async operations and assertions using standard Promises.

Extensible

Add additional helpers specific to your app using the command API.

Compatible

Can be used with any testing library like Mocha, Jasmine, AVA, and Chai.

Get started

# 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)
})

Dive deeper and read the API docs.