forked from bcgov/mem-mmti-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e.ts
57 lines (53 loc) · 1.32 KB
/
e2e.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const path = require('path');
const childProcess = require('child_process');
const e2e_server_process = start_e2e_server();
run_e2e_tests();
/**
* Start the application.
* Calling 'ng serve' through node is necessary in order to maintain a handle to the process that can be killed later.
*/
function start_e2e_server() {
console.log('start_e2e_server');
return childProcess
.spawn('node', ['./node_modules/@angular/cli/bin/ng', 'serve'], {
env: process.env,
detached: true,
shell: false,
stdio: 'ignore'
})
.on('error', error => {
shutdown_e2e_server();
})
.on('close', close => {
shutdown_e2e_server();
});
}
/**
* Run the functional end-to-end tests.
* Refer to functional-tests/readme.md for more information.
*/
function run_e2e_tests() {
console.log('run_e2e_tests');
childProcess
.spawn(
process.platform === 'win32' ? 'gradlew.bat' : './gradlew',
['chromeHeadlessTest'],
{
env: process.env,
cwd: path.join(process.cwd(), 'functional-tests'),
stdio: 'inherit'
}
)
.on('exit', exit => {
shutdown_e2e_server();
});
}
/**
* Stop the application.
*/
function shutdown_e2e_server() {
if (e2e_server_process) {
console.log('shutdown_e2e_server');
e2e_server_process.kill('SIGINT');
}
}