Skip to main content
1 of 2

You can find a code example on the official Github page To get started, have a look at this code snippet:

# 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 () {
  return app.browserWindow.isVisible()
}).then(function (isVisible) {
  // Verify the window is visible
  assert.equal(isVisible, true)
}.catch(function (error) {
  console.error('Test failed', error.message)
})

This is an extract taken from the official site.

You want to install chai and chai-as-promised as well.

npm install --save-dev chai
npm install --save-dev chai-as-promised

Chai is a BDD / TDD assertion library for node and the second one extends it with assertions about promises.