/
setup.js
62 lines (52 loc) 路 1.2 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use strict';
var chromeDriverProcess;
var chaiAsPromised = require('chai-as-promised');
var childProcess = require('child_process');
var chromedriver = require('chromedriver');
var webdriverio = require('webdriverio');
var kakuPath;
// Note
// we only support Mac & linux platform for uitest for now.
switch (process.platform) {
case 'darwin':
kakuPath = './build/app/Kaku.app/Contents/MacOS/Electron';
break;
default:
kakuPath = './build/app/Kaku';
break;
}
var client = webdriverio.remote({
host: 'localhost',
port: 9515,
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
binary: kakuPath
}
}
});
var assert = require('assert');
var chai = require('chai');
// Note
// we will create a child process for chromeDriver when running tests
beforeEach((done) => {
chromeDriverProcess = childProcess.execFile(chromedriver.path, [
'--url-base=/wd/hub',
'--port=9515'
], function(error) {
if (error) {
process.exit(1);
}
else {
done();
}
}});
});
afterEach(() => {
if (chromeDriverProcess !== null) {
chromeDriverProcess.kill();
}
});
chai.use(chaiAsPromised);
global.assert = chai.assert;
global.Kaku = client;