Using Chai and Chai as Promised pairs well with WebDriverIO and, hence, with Spectron. Using these together allows you to chain the assertions together and have fewer callback blocks. This is another option for using the Spectron test cases. Install the libraries using npm:
npm install --save-dev chai npm install --save-dev chai-as-promised
The same preceding code can be rewritten using Chai, as follows. Let's check it part by part. Initialize the skeleton of the test case, as follows:
var Application = require('spectron').Application; var chai = require('chai'); var chaiAsPromised = require('chai-as-promised'); var path = require('path'); chai.should(); chai.use(chaiAsPromised); describe('application launch', function() { this.timeout(10000); beforeEach(function() { this.app = new Application({ path: './node_modules/.bin/electron', args: ['main.js'] }); return this.app.start(); }); beforeEach(function (...