-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke.js
67 lines (53 loc) · 1.57 KB
/
smoke.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
63
64
65
66
67
/* eslint-disable @typescript-eslint/no-var-requires */
// A simple test to verify a visible window is opened with a title and some text
const path = require('path');
const Application = require('spectron').Application;
process.on('unhandledRejection', error => {
console.error(error);
process.exit(1);
});
(async () => {
let execPath;
switch (process.platform) {
case 'win32':
execPath = path.join(__dirname, '.\\artifacts\\win-unpacked\\Octosign.exe');
break;
case 'darwin':
execPath = path.join(__dirname, './artifacts/mac/Octosign.app/Contents/MacOS/Octosign');
break;
case 'linux':
execPath = path.join(__dirname, './artifacts/linux-unpacked/com.octosign');
break;
default:
throw new Error('Unknown platform.');
}
const app = new Application({
path: execPath,
requireName: 'spectronRequire',
env: {
ELECTRON_IS_DEV: '0',
SPECTRON: '1',
},
});
// Assume tests failed if it takes longer than 15 seconds
const timeout = setTimeout(() => {
console.error('Smoke test failed on timeout ✕');
try {
app.quit();
} catch (e) {}
process.exit(1);
}, 15 * 1000);
await app.start();
const isVisible = await app.browserWindow.isVisible();
// Verify the window is visible
if (!isVisible) {
throw new Error('Window is not visible');
}
const title = await app.client.getTitle();
if (title !== 'Octosign') {
throw new Error('App does not have correct title');
}
await app.stop();
clearTimeout(timeout);
console.log('Smoke test passed ✓');
})();