-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommon-setup.ts
41 lines (35 loc) · 1.29 KB
/
common-setup.ts
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
const Application = require('spectron').Application;
const electronPath = require('electron'); // Require Electron from the binaries included in node_modules.
const path = require('path');
export default function setup(): void {
beforeEach(async function () {
this.app = new Application({
// Your electron path can be any binary
// i.e for OSX an example path could be '/Applications/MyApp.app/Contents/MacOS/MyApp'
// But for the sake of the example we fetch it from our node_modules.
path: electronPath,
// Assuming you have the following directory structure
// |__ my project
// |__ ...
// |__ main.js
// |__ package.json
// |__ index.html
// |__ ...
// |__ test
// |__ spec.js <- You are here! ~ Well you should be.
// The following line tells spectron to look and use the main.js file
// and the package.json located 1 level above.
args: [path.join(__dirname, '..')],
webdriverOptions: {}
});
await this.app.start();
const browser = this.app.client;
await browser.waitUntilWindowLoaded();
browser.timeouts('script', 15000);
});
afterEach(function () {
if (this.app && this.app.isRunning()) {
return this.app.stop();
}
});
}