O'Reilly logo

Building Cross-Platform Desktop Applications with Electron by Muhammed Jasim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introduction to Spectron

Spectron is a testing library based on the Chrome driver and WebDriverIO, which targets Electron applications. Spectron can work with any testing framework. We will be using Mocha and Chai to explore the Spectron APIs here. Add Spectron to the project using a package manager, such as npm or yarn:

npm install --save-dev spectron

To run the Spectron tests, you need to install Mocha or any other testing framework. Spectron can easily invoke your Electron application and execute the UI and functionality with the help of Chrome driver and WebDriverIO. A very simple Spectron script is as follows:

const assert = require('assert');const { Application } = require('spectron');describe('Application launch', () => { this.timeout(10000); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required