File tree 2 files changed +9
-4
lines changed
2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ const parameterTypeRegistry = new ParameterTypeRegistry();
25
25
const matchStep = ( step ) => {
26
26
for ( const stepName in steps ) {
27
27
if ( stepName . indexOf ( '/' ) === 0 ) {
28
- const res = step . match ( new RegExp ( stepName . slice ( 1 , - 1 ) ) ) ;
28
+ const regExpArr = stepName . match ( new RegExp ( '^/(.*?)/([gimy]*)$' ) ) || [ ] ;
29
+ const res = step . match ( new RegExp ( regExpArr [ 1 ] , regExpArr [ 2 ] ) ) ;
29
30
if ( res ) {
30
31
const fn = steps [ stepName ] ;
31
32
fn . params = res . slice ( 1 ) ;
@@ -56,6 +57,7 @@ module.exports = {
56
57
Given : addStep ,
57
58
When : addStep ,
58
59
Then : addStep ,
60
+ And : addStep ,
59
61
matchStep,
60
62
getSteps,
61
63
clearSteps,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const { Parser } = require('gherkin');
3
3
const {
4
4
Given,
5
5
When,
6
+ And,
6
7
Then,
7
8
matchStep,
8
9
clearSteps,
@@ -64,10 +65,12 @@ describe('BDD', () => {
64
65
it ( 'should load step definitions' , ( ) => {
65
66
Given ( 'I am a bird' , ( ) => 1 ) ;
66
67
When ( 'I fly over ocean' , ( ) => 2 ) ;
67
- Then ( / I s e e ( .* ?) / , ( ) => 3 ) ;
68
+ And ( / ^ I f l y o v e r l a n d $ / i, ( ) => 3 ) ;
69
+ Then ( / I s e e ( .* ?) / , ( ) => 4 ) ;
68
70
expect ( 1 ) . is . equal ( matchStep ( 'I am a bird' ) ( ) ) ;
69
- expect ( 3 ) . is . equal ( matchStep ( 'I see ocean' ) ( ) ) ;
70
- expect ( 3 ) . is . equal ( matchStep ( 'I see world' ) ( ) ) ;
71
+ expect ( 3 ) . is . equal ( matchStep ( 'I Fly oVer Land' ) ( ) ) ;
72
+ expect ( 4 ) . is . equal ( matchStep ( 'I see ocean' ) ( ) ) ;
73
+ expect ( 4 ) . is . equal ( matchStep ( 'I see world' ) ( ) ) ;
71
74
} ) ;
72
75
73
76
it ( 'should contain tags' , async ( ) => {
You can’t perform that action at this time.
0 commit comments