1- const { CucumberExpression, ParameterTypeRegistry, ParameterType } = require ( '@cucumber/cucumber-expressions' ) ;
2- const Config = require ( '../config' ) ;
1+ const { CucumberExpression, ParameterTypeRegistry, ParameterType } = require ( '@cucumber/cucumber-expressions' )
2+ const Config = require ( '../config' )
33
4- let steps = { } ;
4+ let steps = { }
55
6- const STACK_POSITION = 2 ;
6+ const STACK_POSITION = 2
77
88/**
99 * @param {* } step
1010 * @param {* } fn
1111 */
1212const addStep = ( step , fn ) => {
13- const avoidDuplicateSteps = Config . get ( 'gherkin' , { } ) . avoidDuplicateSteps || false ;
14- const stack = new Error ( ) . stack ;
13+ const avoidDuplicateSteps = Config . get ( 'gherkin' , { } ) . avoidDuplicateSteps || false
14+ const stack = new Error ( ) . stack
1515 if ( avoidDuplicateSteps && steps [ step ] ) {
16- throw new Error ( `Step '${ step } ' is already defined` ) ;
16+ throw new Error ( `Step '${ step } ' is already defined` )
1717 }
18- steps [ step ] = fn ;
19- fn . line = stack && stack . split ( '\n' ) [ STACK_POSITION ] ;
18+ steps [ step ] = fn
19+ fn . line = stack && stack . split ( '\n' ) [ STACK_POSITION ]
2020 if ( fn . line ) {
2121 fn . line = fn . line
2222 . trim ( )
2323 . replace ( / ^ a t ( .* ?) \( / , '(' )
24- . replace ( codecept_dir , '.' ) ;
24+ . replace ( codecept_dir , '.' )
2525 }
26- } ;
26+ }
2727
28- const parameterTypeRegistry = new ParameterTypeRegistry ( ) ;
28+ const parameterTypeRegistry = new ParameterTypeRegistry ( )
2929
3030const matchStep = step => {
3131 for ( const stepName in steps ) {
3232 if ( stepName . indexOf ( '/' ) === 0 ) {
33- const regExpArr = stepName . match ( / ^ \/ ( .* ?) \/ ( [ g i m y ] * ) $ / ) || [ ] ;
34- const res = step . match ( new RegExp ( regExpArr [ 1 ] , regExpArr [ 2 ] ) ) ;
33+ const regExpArr = stepName . match ( / ^ \/ ( .* ?) \/ ( [ g i m y ] * ) $ / ) || [ ]
34+ const res = step . match ( new RegExp ( regExpArr [ 1 ] , regExpArr [ 2 ] ) )
3535 if ( res ) {
36- const fn = steps [ stepName ] ;
37- fn . params = res . slice ( 1 ) ;
38- return fn ;
36+ const fn = steps [ stepName ]
37+ fn . params = res . slice ( 1 )
38+ return fn
3939 }
40- continue ;
40+ continue
4141 }
42- const expression = new CucumberExpression ( stepName , parameterTypeRegistry ) ;
43- const res = expression . match ( step ) ;
42+ const expression = new CucumberExpression ( stepName , parameterTypeRegistry )
43+ const res = expression . match ( step )
4444 if ( res ) {
45- const fn = steps [ stepName ] ;
46- fn . params = res . map ( arg => arg . getValue ( ) ) ;
47- return fn ;
45+ const fn = steps [ stepName ]
46+ fn . params = res . map ( arg => arg . getValue ( ) )
47+ return fn
4848 }
4949 }
50- throw new Error ( `No steps matching "${ step . toString ( ) } "` ) ;
51- } ;
50+ throw new Error ( `No steps matching "${ step . toString ( ) } "` )
51+ }
5252
5353const clearSteps = ( ) => {
54- steps = { } ;
55- } ;
54+ steps = { }
55+ }
5656
5757const getSteps = ( ) => {
58- return steps ;
59- } ;
58+ return steps
59+ }
6060
6161const defineParameterType = options => {
62- const parameterType = buildParameterType ( options ) ;
63- parameterTypeRegistry . defineParameterType ( parameterType ) ;
64- } ;
62+ const parameterType = buildParameterType ( options )
63+ parameterTypeRegistry . defineParameterType ( parameterType )
64+ }
6565
6666const buildParameterType = ( { name, regexp, transformer, useForSnippets, preferForRegexpMatch } ) => {
67- if ( typeof useForSnippets !== 'boolean' ) useForSnippets = true ;
68- if ( typeof preferForRegexpMatch !== 'boolean' ) preferForRegexpMatch = false ;
69- return new ParameterType ( name , regexp , null , transformer , useForSnippets , preferForRegexpMatch ) ;
70- } ;
67+ if ( typeof useForSnippets !== 'boolean' ) useForSnippets = true
68+ if ( typeof preferForRegexpMatch !== 'boolean' ) preferForRegexpMatch = false
69+ return new ParameterType ( name , regexp , null , transformer , useForSnippets , preferForRegexpMatch )
70+ }
7171
7272module . exports = {
7373 Given : addStep ,
@@ -78,4 +78,4 @@ module.exports = {
7878 getSteps,
7979 clearSteps,
8080 defineParameterType,
81- } ;
81+ }
0 commit comments