@@ -13,19 +13,35 @@ let removeDuplicates = (arr, newArr = []) => {
1313 return newArr ;
1414} ;
1515
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' ) {
1828 var phantomSource = require ( 'phantomjs-prebuilt' ) . path ;
1929
2030 // If the path we're given by phantomjs is to a .cmd, it is pointing to a global copy on Windows.
2131 // Using the cmd as the process to execute causes problems cleaning up the processes
2232 // 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' ) ;
2535 }
2636
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+ }
2945} ;
3046
3147var getGemini = function ( options ) {
@@ -97,9 +113,9 @@ module.exports.test = function(options) {
97113 var test = function ( file , enc , callback ) {
98114
99115 var gemini = getGemini ( options ) ;
100-
101- // Run PhantomJs
102- runPhantom ( ) ;
116+
117+ // Run test server
118+ runTestServer ( options . testServer ) ;
103119
104120 // Clean report
105121 fs . removeSync ( options . reportDir + '/*' ) ;
@@ -114,7 +130,7 @@ module.exports.test = function(options) {
114130 tempDir : options . reportDir
115131 } ) ;
116132 runTestsPromise . done ( result => {
117- phantomProcess . kill ( 'SIGTERM' ) ;
133+ serverProcess . kill ( 'SIGTERM' ) ;
118134 spawn ( 'open' , [ `${ options . reportDir } /index.html` ] ) . on ( 'error' , function ( ) { } ) ;
119135 } ) ;
120136 } ;
@@ -238,8 +254,8 @@ module.exports.gather = function(options) {
238254
239255 var gemini = getGemini ( options ) ;
240256
241- // Run PhantomJs
242- runPhantom ( ) ;
257+ // Run test server
258+ runTestServer ( options . testServer ) ;
243259
244260 // Clean screenshot
245261 if ( ! options . sections ) { // only for full replacement
@@ -254,7 +270,7 @@ module.exports.gather = function(options) {
254270 reporters : [ 'flat' ] ,
255271 } )
256272 . done ( result => {
257- phantomProcess . kill ( 'SIGTERM' ) ;
273+ serverProcess . kill ( 'SIGTERM' ) ;
258274 } ) ;
259275 }
260276 // TODO: remake with promises
0 commit comments