@@ -13,19 +13,35 @@ let removeDuplicates = (arr, newArr = []) => {
13
13
return newArr ;
14
14
} ;
15
15
16
- var phantomProcess ;
17
- var runPhantom = function ( ) {
16
+ var serverProcess ;
17
+
18
+ var runTestServer = function runTestServer ( testServer ) {
19
+
20
+ if ( ! testServer ) {
21
+ testServer = 'phantom' ;
22
+ }
23
+
24
+ console . log ( 'Test server:' , testServer . toUpperCase ( ) ) ;
25
+
26
+ // Run test server
27
+ if ( testServer === 'phantom' ) {
18
28
var phantomSource = require ( 'phantomjs-prebuilt' ) . path ;
19
29
20
30
// If the path we're given by phantomjs is to a .cmd, it is pointing to a global copy on Windows.
21
31
// Using the cmd as the process to execute causes problems cleaning up the processes
22
32
// so we walk from the cmd to the phantomjs.exe and use that instead.
23
- if ( path . extname ( phantomSource ) . toLowerCase ( ) === '.cmd' ) {
24
- phantomSource = path . join ( path . dirname ( phantomSource ) , '//node_modules//phantomjs//lib//phantom//phantomjs.exe' ) ;
33
+ if ( path . extname ( phantomSource ) . toLowerCase ( ) === '.cmd' ) {
34
+ phantomSource = path . join ( path . dirname ( phantomSource ) , '//node_modules//phantomjs//lib//phantom//phantomjs.exe' ) ;
25
35
}
26
36
27
- phantomProcess = spawn ( phantomSource , [ '--webdriver' , '4444' , '--disk-cache' , 'false' , '--ignore-ssl-errors' , 'true' ] , { setsid :true } ) ;
28
- phantomProcess . stdout . pipe ( process . stdout ) ;
37
+ serverProcess = spawn ( phantomSource , [ '--webdriver' , '4444' , '--disk-cache' , 'false' , '--ignore-ssl-errors' , 'true' ] , { setsid : true } ) ;
38
+ serverProcess . stdout . pipe ( process . stdout ) ;
39
+ }
40
+
41
+ if ( testServer === 'selenium' ) {
42
+ serverProcess = spawn ( 'selenium-standalone' , [ 'start' ] , { setsid : true , detached :true } ) ;
43
+ serverProcess . stdout . pipe ( process . stdout ) ;
44
+ }
29
45
} ;
30
46
31
47
var getGemini = function ( options ) {
@@ -97,9 +113,9 @@ module.exports.test = function(options) {
97
113
var test = function ( file , enc , callback ) {
98
114
99
115
var gemini = getGemini ( options ) ;
100
-
101
- // Run PhantomJs
102
- runPhantom ( ) ;
116
+
117
+ // Run test server
118
+ runTestServer ( options . testServer ) ;
103
119
104
120
// Clean report
105
121
fs . removeSync ( options . reportDir + '/*' ) ;
@@ -114,7 +130,7 @@ module.exports.test = function(options) {
114
130
tempDir : options . reportDir
115
131
} ) ;
116
132
runTestsPromise . done ( result => {
117
- phantomProcess . kill ( 'SIGTERM' ) ;
133
+ serverProcess . kill ( 'SIGTERM' ) ;
118
134
spawn ( 'open' , [ `${ options . reportDir } /index.html` ] ) . on ( 'error' , function ( ) { } ) ;
119
135
} ) ;
120
136
} ;
@@ -238,8 +254,8 @@ module.exports.gather = function(options) {
238
254
239
255
var gemini = getGemini ( options ) ;
240
256
241
- // Run PhantomJs
242
- runPhantom ( ) ;
257
+ // Run test server
258
+ runTestServer ( options . testServer ) ;
243
259
244
260
// Clean screenshot
245
261
if ( ! options . sections ) { // only for full replacement
@@ -254,7 +270,7 @@ module.exports.gather = function(options) {
254
270
reporters : [ 'flat' ] ,
255
271
} )
256
272
. done ( result => {
257
- phantomProcess . kill ( 'SIGTERM' ) ;
273
+ serverProcess . kill ( 'SIGTERM' ) ;
258
274
} ) ;
259
275
}
260
276
// TODO: remake with promises
0 commit comments