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); beforeEach(() => { this.app = new Application({ path: '/Applications/AppName/Contents/MacOS/App' }); return this.app.start(); }); afterEach(() => { if(this.app && this.app...