2525
2626import { Journey , JourneyCallback , JourneyOptions } from '../dsl' ;
2727import Runner from './runner' ;
28- import { VoidCallback , HooksCallback } from '../common_types' ;
28+ import { VoidCallback , HooksCallback , Location } from '../common_types' ;
29+ import { wrapFnWithLocation } from '../helpers' ;
2930import { log } from './logger' ;
3031
3132/**
@@ -39,23 +40,28 @@ if (!global[SYNTHETICS_RUNNER]) {
3940
4041export const runner : Runner = global [ SYNTHETICS_RUNNER ] ;
4142
42- export const journey = (
43- options : JourneyOptions | string ,
44- callback : JourneyCallback
45- ) => {
46- log ( `register journey: ${ JSON . stringify ( options ) } ` ) ;
47- if ( typeof options === 'string' ) {
48- options = { name : options , id : options } ;
43+ export const journey = wrapFnWithLocation (
44+ (
45+ location : Location ,
46+ options : JourneyOptions | string ,
47+ callback : JourneyCallback
48+ ) => {
49+ log ( `register journey: ${ JSON . stringify ( options ) } ` ) ;
50+ if ( typeof options === 'string' ) {
51+ options = { name : options , id : options } ;
52+ }
53+ const j = new Journey ( options , callback , location ) ;
54+ runner . addJourney ( j ) ;
55+ return j ;
4956 }
50- const j = new Journey ( options , callback ) ;
51- runner . addJourney ( j ) ;
52- return j ;
53- } ;
57+ ) ;
5458
55- export const step = ( name : string , callback : VoidCallback ) => {
56- log ( `register step: ${ name } ` ) ;
57- return runner . currentJourney ?. addStep ( name , callback ) ;
58- } ;
59+ export const step = wrapFnWithLocation (
60+ ( location : Location , name : string , callback : VoidCallback ) => {
61+ log ( `register step: ${ name } ` ) ;
62+ return runner . currentJourney ?. addStep ( name , callback , location ) ;
63+ }
64+ ) ;
5965
6066export const beforeAll = ( callback : HooksCallback ) => {
6167 runner . addHook ( 'beforeAll' , callback ) ;
0 commit comments