Skip to content

Commit c9c1182

Browse files
committed
Add spectron, mocha and setup basic application test
1 parent 3d9fc04 commit c9c1182

File tree

4 files changed

+620
-16
lines changed

4 files changed

+620
-16
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function createWindow() {
2929
);
3030

3131
// Open the DevTools.
32-
mainWindow.webContents.openDevTools();
32+
// mainWindow.webContents.openDevTools();
3333

3434
// Emitted when the window is closed.
3535
mainWindow.on('closed', function() {

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"scripts": {
1010
"start": "electron .",
1111
"lint": "eslint **/*.js",
12-
"inspect-main": "electron-inspector"
12+
"inspect-main": "electron-inspector",
13+
"test": "mocha"
1314
},
1415
"devDependencies": {
1516
"babel-core": "^6.24.0",
@@ -24,7 +25,9 @@
2425
"eslint-plugin-jsx-a11y": "^4.0.0",
2526
"eslint-plugin-prettier": "^2.0.1",
2627
"eslint-plugin-react": "^6.10.3",
27-
"prettier": "^0.22.0"
28+
"mocha": "^3.4.2",
29+
"prettier": "^0.22.0",
30+
"spectron": "^3.7.2"
2831
},
2932
"dependencies": {
3033
"axios": "^0.16.1",

test/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-env node, mocha */
2+
const assert = require('assert');
3+
const path = require('path');
4+
const {Application} = require('spectron');
5+
6+
// construct paths
7+
const baseDir = path.join(__dirname, '..');
8+
const electronBinary = path.join(baseDir, 'node_modules', '.bin', 'electron');
9+
10+
describe('Application launch', function() {
11+
this.timeout(10000);
12+
13+
const app = new Application({
14+
path: electronBinary,
15+
args: [baseDir],
16+
});
17+
18+
beforeEach(() => app.start());
19+
20+
afterEach(() => app.stop());
21+
22+
it('Shows an initial window', async () => {
23+
const count = await app.client.getWindowCount();
24+
assert.equal(count, 1);
25+
});
26+
});

0 commit comments

Comments
 (0)