Electron and Spectron

Introduction 

 
Electron is an open-source framework developed by GIT Hub to design Desktop applications.
 
There are many commonly used apps that are developed using Electron, such as VSCode, Slack, Skype, etc…
 
The advantages of using Electron over other frameworks are:
  • Open-Source
  • Cross-Platform
  • Supports CSS, HTML, and Javascript
  • Can be used with Chromium and Node JS
To Install Electron:
  1. Download Nodejs and install it
  2. From a command prompt or any editor like VSCode, just type npm install electron
This creates a basic electron app with index.js and index.html
 
Spectron is a framework that is used to write automated test cases for an electron app. This is based on WebdriverIO and ChromeDriver, hence it can be easily used to write automated integrations tests.
 
Electron only supports Spectron, but not other test frameworks. This is because Electron applications don’t have a web URL and also there are certain APIs for Electron that are not compatible with a web browser.
 
Spectron, as a framework, has the capability to simply launch the electron application, but not to run the tests. To run tests, programmers have to use other testing libraries like mocha/jasmine. Therefore, while using/installing Spectron, programmers must use/install mocha/jasmine.
 
Spectron Installation Commands:
  1. Npm install Spectron
  2. Npm install jasmine
Once done, along with the application it will create a basic test structure for your application.