forked from atlassian/react-beautiful-dnd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser-test-harness.js
51 lines (47 loc) · 1.07 KB
/
browser-test-harness.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
// @flow
const childProcess = require('child_process');
const path = require('path');
const waitPort = require('wait-port');
const storybook = childProcess.spawn(process.execPath, [
path.join('node_modules', '.bin', 'start-storybook'),
'-p',
'9002',
]);
const standalone = childProcess.spawn(process.execPath, [
path.join('test', 'standalone', 'start.sh'),
'9003',
]);
process.on('exit', () => {
storybook.kill();
standalone.kill();
});
Promise.all([
waitPort({
host: 'localhost',
port: 9003,
timeout: 60000,
}),
waitPort({
host: 'localhost',
port: 9002,
timeout: 60000,
}),
])
.then(() => {
const child = childProcess.spawn(process.argv[2], process.argv.slice(3), {
stdio: 'inherit',
});
process.on('exit', () => {
child.kill();
});
child.on('exit', code => {
process.exit(code);
});
})
.catch(() => {
// eslint-disable-next-line no-console
console.error('Storybook or our stand alone server did not start in time');
storybook.kill();
standalone.kill();
process.exit(1);
});