File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 22
33/* Used to detect Gherkin steps */
44
5- const util = require ( 'util' ) ;
6-
75let eventsQueue = [ ] ;
86let testRunStarted = false ;
97
Original file line number Diff line number Diff line change @@ -284,6 +284,10 @@ const getCypressCommandEventListener = (isJS) => {
284284 )
285285}
286286
287+ const isE2ESupportFile = ( file ) => {
288+ return file . includes ( 'e2e.js' ) || file . includes ( 'e2e.ts' ) ;
289+ }
290+
287291exports . setEventListeners = ( bsConfig ) => {
288292 try {
289293 const supportFilesData = helper . getSupportFiles ( bsConfig , false ) ;
@@ -292,7 +296,7 @@ exports.setEventListeners = (bsConfig) => {
292296 if ( err ) return exports . debug ( 'EXCEPTION IN BUILD START EVENT : Unable to parse cypress support files' ) ;
293297 files . forEach ( file => {
294298 try {
295- if ( ! file . includes ( 'commands.js' ) ) {
299+ if ( isE2ESupportFile ( file ) || ! files . some ( f => isE2ESupportFile ( f ) ) ) {
296300 const defaultFileContent = fs . readFileSync ( file , { encoding : 'utf-8' } ) ;
297301
298302 let cypressCommandEventListener = getCypressCommandEventListener ( file . includes ( 'js' ) ) ;
Original file line number Diff line number Diff line change @@ -270,6 +270,16 @@ class MyReporter {
270270
271271 const port = process . env . REPORTER_API_PORT_NO ;
272272
273+ this . httpServer . on ( 'error' , ( error ) => {
274+ if ( error . code === 'EADDRINUSE' ) {
275+ debugOnConsole ( `Port ${ port } is already in use. HTTP server could not start.` ) ;
276+ debug ( `Port ${ port } is already in use. HTTP server could not start.` , true , error ) ;
277+ } else {
278+ debugOnConsole ( `Exception in starting reporter server : ${ error } ` ) ;
279+ debug ( `Exception in starting reporter server : ${ error } ` , true , error ) ;
280+ }
281+ } ) ;
282+
273283 this . httpServer . listen ( port , '127.0.0.1' , async ( ) => {
274284 console . log ( `Reporter HTTP server listening on port ${ port } ` ) ;
275285 } ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const TESTHUB_CONSTANTS = require("./constants");
55const testObservabilityHelper = require ( "../../bin/testObservability/helper/helper" ) ;
66const helper = require ( "../helpers/helper" ) ;
77const accessibilityHelper = require ( "../accessibility-automation/helper" ) ;
8- const { detect } = require ( 'detect-port' ) ;
8+ const detectPort = require ( 'detect-port' ) ;
99
1010
1111const isUndefined = ( value ) => value === undefined || value === null ;
@@ -195,17 +195,18 @@ exports.logBuildError = (error, product = "") => {
195195 }
196196} ;
197197
198- exports . findAvailablePort = async ( preferredPort , maxAttempts = 10 ) => {
198+ exports . findAvailablePort = async ( preferredPort , maxAttempts = 10 ) => {
199+ const findPort = detectPort . detect || detectPort ;
199200 let port = preferredPort ;
200201 for ( let attempts = 0 ; attempts < maxAttempts ; attempts ++ ) {
201202 try {
202- const availablePort = await detect ( port ) ;
203+ const availablePort = await findPort ( port ) ;
203204
204205 if ( availablePort === port ) {
205206 return port ;
206207 } else {
207208 // Double-check suggested port
208- const verify = await detect ( availablePort ) ;
209+ const verify = await findPort ( availablePort ) ;
209210 if ( verify === availablePort ) {
210211 return availablePort ;
211212 }
You can’t perform that action at this time.
0 commit comments