@@ -45,10 +45,7 @@ import {
4545 StepResult ,
4646 PushOptions ,
4747} from '../common_types' ;
48- import {
49- PerformanceManager ,
50- filterBrowserMessages ,
51- } from '../plugins' ;
48+ import { PerformanceManager , filterBrowserMessages } from '../plugins' ;
5249import { Gatherer } from './gatherer' ;
5350import { log } from './logger' ;
5451import { Monitor , MonitorConfig } from '../dsl/monitor' ;
@@ -104,7 +101,7 @@ export default class Runner implements RunnerInfo {
104101 type : 'jpeg' ,
105102 quality : 80 ,
106103 timeout : 5000 ,
107- } )
104+ } ) ;
108105 /**
109106 * Write the screenshot image buffer with additional details (step
110107 * information) which could be extracted at the end of
@@ -131,8 +128,20 @@ export default class Runner implements RunnerInfo {
131128 this . #hooks[ type ] . push ( callback ) ;
132129 }
133130
131+ /**
132+ * @deprecated Since version Please do not rely on the internal methods.
133+ * Alias _addHook for backwards compatibility
134+ */
135+ addHook ( type : HookType , callback : HooksCallback ) {
136+ this . _addHook ( type , callback ) ;
137+ }
138+
134139 private buildHookArgs ( ) {
135- return { env : this . config . environment , params : this . config . params , info : this as RunnerInfo } ;
140+ return {
141+ env : this . config . environment ,
142+ params : this . config . params ,
143+ info : this as RunnerInfo ,
144+ } ;
136145 }
137146
138147 _updateMonitor ( config : MonitorConfig ) {
@@ -143,11 +152,27 @@ export default class Runner implements RunnerInfo {
143152 this . #monitor. update ( config ) ;
144153 }
145154
155+ /**
156+ * @deprecated Since version Please do not rely on the internal methods.
157+ * Alias _addJourney for backwards compatibility
158+ */
159+ updateMonitor ( config : MonitorConfig ) {
160+ this . _updateMonitor ( config ) ;
161+ }
162+
146163 _addJourney ( journey : Journey ) {
147164 this . #journeys. push ( journey ) ;
148165 this . #currentJourney = journey ;
149166 }
150167
168+ /**
169+ * @deprecated Since version 1.17.0. Please do not rely on the internal methods.
170+ * Alias _addJourney for backwards compatibility
171+ */
172+ addJourney ( journey : Journey ) {
173+ this . _addJourney ( journey ) ;
174+ }
175+
151176 private setReporter ( options : RunOptions ) {
152177 /**
153178 * Set up the corresponding reporter and fallback
@@ -181,10 +206,7 @@ export default class Runner implements RunnerInfo {
181206 await runParallel ( journey . _getHook ( 'after' ) , args ) ;
182207 }
183208
184- async #runStep(
185- step : Step ,
186- options : RunOptions
187- ) : Promise < StepResult > {
209+ async #runStep( step : Step , options : RunOptions ) : Promise < StepResult > {
188210 log ( `Runner: start step (${ step . name } )` ) ;
189211 const { metrics, screenshots, filmstrips, trace } = options ;
190212 /**
@@ -212,7 +234,7 @@ export default class Runner implements RunnerInfo {
212234 // invoke the step callback by extracting to a variable to get better stack trace
213235 const cb = step . cb ;
214236 await cb ( ) ;
215- step . status = " succeeded"
237+ step . status = ' succeeded' ;
216238 } catch ( error ) {
217239 step . status = 'failed' ;
218240 step . error = error ;
@@ -245,13 +267,10 @@ export default class Runner implements RunnerInfo {
245267 }
246268 }
247269 log ( `Runner: end step (${ step . name } )` ) ;
248- return data
270+ return data ;
249271 }
250272
251- async #runSteps(
252- journey : Journey ,
253- options : RunOptions
254- ) {
273+ async #runSteps( journey : Journey , options : RunOptions ) {
255274 const results : Array < StepResult > = [ ] ;
256275 const isOnlyExists = journey . steps . filter ( s => s . only ) . length > 0 ;
257276 let skipStep = false ;
@@ -297,7 +316,7 @@ export default class Runner implements RunnerInfo {
297316 * caching all screenshots and clear them at end of each journey
298317 */
299318 await mkdir ( this . #screenshotPath, { recursive : true } ) ;
300- const params = options . params
319+ const params = options . params ;
301320 this . #reporter?. onJourneyStart ?.( journey , {
302321 timestamp : getTimestamp ( ) ,
303322 params,
@@ -315,7 +334,10 @@ export default class Runner implements RunnerInfo {
315334 ) {
316335 // Enhance the journey results
317336 const pOutput = await Gatherer . pluginManager . output ( ) ;
318- const bConsole = filterBrowserMessages ( pOutput . browserconsole , journey . status ) ;
337+ const bConsole = filterBrowserMessages (
338+ pOutput . browserconsole ,
339+ journey . status
340+ ) ;
319341 await this . #reporter?. onJourneyEnd ?.( journey , {
320342 browserDelay : this . #browserDelay,
321343 timestamp : getTimestamp ( ) ,
@@ -324,7 +346,7 @@ export default class Runner implements RunnerInfo {
324346 browserconsole : bConsole ,
325347 } ) ;
326348 await Gatherer . endRecording ( ) ;
327- await Gatherer . dispose ( this . #driver)
349+ await Gatherer . dispose ( this . #driver) ;
328350 // clear screenshots cache after each journey
329351 await rm ( this . #screenshotPath, { recursive : true , force : true } ) ;
330352 return Object . assign ( result , {
@@ -361,12 +383,16 @@ export default class Runner implements RunnerInfo {
361383 this . #currentJourney = journey ;
362384 log ( `Runner: start journey (${ journey . name } )` ) ;
363385 let result : JourneyResult = { } ;
364- const hookArgs = { env : options . environment , params : options . params , info : this } ;
386+ const hookArgs = {
387+ env : options . environment ,
388+ params : options . params ,
389+ info : this ,
390+ } ;
365391 try {
366392 await this . #startJourney( journey , options ) ;
367393 await this . #runBeforeHook( journey , hookArgs ) ;
368394 const stepResults = await this . #runSteps( journey , options ) ;
369- journey . status = " succeeded" ;
395+ journey . status = ' succeeded' ;
370396 // Mark journey as failed if any one of the step fails
371397 for ( const step of journey . steps ) {
372398 if ( step . status === 'failed' ) {
@@ -385,13 +411,21 @@ export default class Runner implements RunnerInfo {
385411 await this . #runAfterHook( journey , hookArgs ) . catch ( e => {
386412 journey . status = 'failed' ;
387413 journey . error = e ;
388- } )
414+ } ) ;
389415 result = await this . #endJourney( journey , result , options ) ;
390416 }
391417 log ( `Runner: end journey (${ journey . name } )` ) ;
392418 return result ;
393419 }
394420
421+ /**
422+ * @deprecated Since version 1.17.0. Please do not rely on the internal methods.
423+ * Alias _runJourney for backwards compatibility
424+ */
425+ runJourney ( journey : Journey , options : RunOptions ) {
426+ this . _runJourney ( journey , options ) ;
427+ }
428+
395429 _buildMonitors ( options : PushOptions ) {
396430 /**
397431 * Update the global monitor configuration required for setting defaults
@@ -426,15 +460,12 @@ export default class Runner implements RunnerInfo {
426460 * - filter out monitors based on matched tags and name after applying both
427461 * global and local monitor configurations
428462 */
429- journey . cb ( { params : options . params } as any ) ;
430- const monitor = journey . _getMonitor ( ) ;
463+
464+ // TODO: Fix backwards compatibility with 1.14 and prior
465+ ( journey . cb ?? journey . callback ) ( { params : options . params } as any ) ;
466+ const monitor = journey . monitor ?? journey ?. _getMonitor ( ) ;
431467 monitor . update ( this . #monitor?. config ) ;
432- if (
433- ! monitor . isMatch (
434- options . grepOpts ?. match ,
435- options . grepOpts ?. tags
436- )
437- ) {
468+ if ( ! monitor . isMatch ( options . grepOpts ?. match , options . grepOpts ?. tags ) ) {
438469 continue ;
439470 }
440471 monitor . validate ( ) ;
@@ -443,6 +474,14 @@ export default class Runner implements RunnerInfo {
443474 return monitors ;
444475 }
445476
477+ /**
478+ * @deprecated Since version 1.17.0. Please do not rely on the internal methods.
479+ * Alias _buildMonitors for backwards compatibility
480+ */
481+ buildMonitors ( options : PushOptions ) {
482+ this . _buildMonitors ( options ) ;
483+ }
484+
446485 async #init( options : RunOptions ) {
447486 this . setReporter ( options ) ;
448487 this . #reporter. onStart ?.( {
@@ -474,20 +513,34 @@ export default class Runner implements RunnerInfo {
474513 this . #journeys = onlyJournerys ;
475514 } else {
476515 // filter journeys based on tags and skip annotations
477- this . #journeys = this . #journeys. filter ( j => j . _isMatch ( grepOpts ?. match , grepOpts ?. tags ) && ! j . skip ) ;
516+ this . #journeys = this . #journeys. filter (
517+ j => j . _isMatch ( grepOpts ?. match , grepOpts ?. tags ) && ! j . skip
518+ ) ;
478519 }
479520
480521 // Used by heartbeat to gather all registered journeys
481522 if ( dryRun ) {
482- this . #journeys. forEach ( journey => this . #reporter. onJourneyRegister ?.( journey ) )
523+ this . #journeys. forEach ( journey =>
524+ this . #reporter. onJourneyRegister ?.( journey )
525+ ) ;
483526 } else if ( this . #journeys. length > 0 ) {
484527 result = await this . _runJourneys ( options ) ;
485528 }
486- await this . #runAfterAllHook( hookArgs ) . catch ( async ( ) => await this . _reset ( ) ) ;
529+ await this . #runAfterAllHook( hookArgs ) . catch (
530+ async ( ) => await this . _reset ( )
531+ ) ;
487532 await this . _reset ( ) ;
488533 return result ;
489534 }
490535
536+ /**
537+ * @deprecated Since version 1.17.0. Please do not rely on the internal methods.
538+ * Alias _run for backwards compatibility
539+ */
540+ run ( options : RunOptions ) : Promise < RunResult > {
541+ return this . _run ( options ) ;
542+ }
543+
491544 async _runJourneys ( options : RunOptions ) {
492545 const result : RunResult = { } ;
493546 const browserStart = monotonicTimeInSeconds ( ) ;
@@ -504,6 +557,14 @@ export default class Runner implements RunnerInfo {
504557 return result ;
505558 }
506559
560+ /**
561+ * @deprecated Since version 1.17.0. Please do not rely on the internal methods.
562+ * Alias _runJourneys for backwards compatibility
563+ */
564+ runJourneys ( options : RunOptions ) : Promise < RunResult > {
565+ return this . _runJourneys ( options ) ;
566+ }
567+
507568 async _reset ( ) {
508569 this . #currentJourney = null ;
509570 this . #journeys = [ ] ;
@@ -515,4 +576,12 @@ export default class Runner implements RunnerInfo {
515576 await rm ( CACHE_PATH , { recursive : true , force : true } ) ;
516577 await this . #reporter?. onEnd ?.( ) ;
517578 }
579+
580+ /**
581+ * @deprecated Since version 1.17.0. Please do not rely on the internal methods.
582+ * Alias _reset for backwards compatibility
583+ */
584+ reset ( ) {
585+ return this . _reset ( ) ;
586+ }
518587}
0 commit comments