forked from germanattanasio/visual-recognition-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcasper-runner.js
41 lines (31 loc) · 985 Bytes
/
casper-runner.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
'use strict';
var spawn = require('child_process').spawn;
require('dotenv').config({silent: true});
if (process.env.GOOGLE_ANALYTICS) {
process.env.GOOGLE_ANALYTICS = process.env.GOOGLE_ANALYTICS.replace(/\"/g, '');
}
if (process.env.API_KEY) {
process.env.API_KEY = process.env.API_KEY.replace(/\"/g, '');
}
var server = require('./app');
var port = process.env.PORT || process.env.VCAP_APP_PORT || 3000;
var toclose = server.listen(port, function() {
console.log('Server running on port: %d', port);
setTimeout(runTests, 10000);
});
var runTests = function() {
var casper = spawn('npm', ['run', 'test-integration']);
casper.stdout.pipe(process.stdout);
casper.on('error', function (error) {
console.log('ERROR: ' + error);
toclose.close(function() {
process.exit(1);
});
});
casper.on('close', function (code) {
toclose.close(function() {
// eslint-disable-next-line no-process-exit
process.exit(code);
});
});
};