Best JavaScript code snippet using cucumber-gherkin
gherkin.js
Source:gherkin.js
...3881 return matchTokenAt_5(token, context);3882 case 6:3883 return matchTokenAt_6(token, context);3884 case 7:3885 return matchTokenAt_7(token, context);3886 case 8:3887 return matchTokenAt_8(token, context);3888 case 9:3889 return matchTokenAt_9(token, context);3890 case 10:3891 return matchTokenAt_10(token, context);3892 case 11:3893 return matchTokenAt_11(token, context);3894 case 12:3895 return matchTokenAt_12(token, context);3896 case 13:3897 return matchTokenAt_13(token, context);3898 case 14:3899 return matchTokenAt_14(token, context);3900 case 15:3901 return matchTokenAt_15(token, context);3902 case 16:3903 return matchTokenAt_16(token, context);3904 case 17:3905 return matchTokenAt_17(token, context);3906 case 18:3907 return matchTokenAt_18(token, context);3908 case 19:3909 return matchTokenAt_19(token, context);3910 case 20:3911 return matchTokenAt_20(token, context);3912 case 21:3913 return matchTokenAt_21(token, context);3914 case 22:3915 return matchTokenAt_22(token, context);3916 case 23:3917 return matchTokenAt_23(token, context);3918 case 24:3919 return matchTokenAt_24(token, context);3920 case 25:3921 return matchTokenAt_25(token, context);3922 case 26:3923 return matchTokenAt_26(token, context);3924 case 28:3925 return matchTokenAt_28(token, context);3926 case 29:3927 return matchTokenAt_29(token, context);3928 case 30:3929 return matchTokenAt_30(token, context);3930 case 31:3931 return matchTokenAt_31(token, context);3932 case 32:3933 return matchTokenAt_32(token, context);3934 case 33:3935 return matchTokenAt_33(token, context);3936 default:3937 throw new Error("Unknown state: " + state);3938 }3939 }3940 // Start3941 function matchTokenAt_0(token, context) {3942 if(match_EOF(context, token)) {3943 build(context, token);3944 return 27;3945 }3946 if(match_Language(context, token)) {3947 startRule(context, 'Feature');3948 startRule(context, 'Feature_Header');3949 build(context, token);3950 return 1;3951 }3952 if(match_TagLine(context, token)) {3953 startRule(context, 'Feature');3954 startRule(context, 'Feature_Header');3955 startRule(context, 'Tags');3956 build(context, token);3957 return 2;3958 }3959 if(match_FeatureLine(context, token)) {3960 startRule(context, 'Feature');3961 startRule(context, 'Feature_Header');3962 build(context, token);3963 return 3;3964 }3965 if(match_Comment(context, token)) {3966 build(context, token);3967 return 0;3968 }3969 if(match_Empty(context, token)) {3970 build(context, token);3971 return 0;3972 }3973 3974 var stateComment = "State: 0 - Start";3975 token.detach();3976 var expectedTokens = ["#EOF", "#Language", "#TagLine", "#FeatureLine", "#Comment", "#Empty"];3977 var error = token.isEof ?3978 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :3979 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);3980 if (self.stopAtFirstError) throw error;3981 addError(context, error);3982 return 0;3983 }3984 // GherkinDocument:0>Feature:0>Feature_Header:0>#Language:03985 function matchTokenAt_1(token, context) {3986 if(match_TagLine(context, token)) {3987 startRule(context, 'Tags');3988 build(context, token);3989 return 2;3990 }3991 if(match_FeatureLine(context, token)) {3992 build(context, token);3993 return 3;3994 }3995 if(match_Comment(context, token)) {3996 build(context, token);3997 return 1;3998 }3999 if(match_Empty(context, token)) {4000 build(context, token);4001 return 1;4002 }4003 4004 var stateComment = "State: 1 - GherkinDocument:0>Feature:0>Feature_Header:0>#Language:0";4005 token.detach();4006 var expectedTokens = ["#TagLine", "#FeatureLine", "#Comment", "#Empty"];4007 var error = token.isEof ?4008 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4009 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4010 if (self.stopAtFirstError) throw error;4011 addError(context, error);4012 return 1;4013 }4014 // GherkinDocument:0>Feature:0>Feature_Header:1>Tags:0>#TagLine:04015 function matchTokenAt_2(token, context) {4016 if(match_TagLine(context, token)) {4017 build(context, token);4018 return 2;4019 }4020 if(match_FeatureLine(context, token)) {4021 endRule(context, 'Tags');4022 build(context, token);4023 return 3;4024 }4025 if(match_Comment(context, token)) {4026 build(context, token);4027 return 2;4028 }4029 if(match_Empty(context, token)) {4030 build(context, token);4031 return 2;4032 }4033 4034 var stateComment = "State: 2 - GherkinDocument:0>Feature:0>Feature_Header:1>Tags:0>#TagLine:0";4035 token.detach();4036 var expectedTokens = ["#TagLine", "#FeatureLine", "#Comment", "#Empty"];4037 var error = token.isEof ?4038 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4039 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4040 if (self.stopAtFirstError) throw error;4041 addError(context, error);4042 return 2;4043 }4044 // GherkinDocument:0>Feature:0>Feature_Header:2>#FeatureLine:04045 function matchTokenAt_3(token, context) {4046 if(match_EOF(context, token)) {4047 endRule(context, 'Feature_Header');4048 endRule(context, 'Feature');4049 build(context, token);4050 return 27;4051 }4052 if(match_Empty(context, token)) {4053 build(context, token);4054 return 3;4055 }4056 if(match_Comment(context, token)) {4057 build(context, token);4058 return 5;4059 }4060 if(match_BackgroundLine(context, token)) {4061 endRule(context, 'Feature_Header');4062 startRule(context, 'Background');4063 build(context, token);4064 return 6;4065 }4066 if(match_TagLine(context, token)) {4067 endRule(context, 'Feature_Header');4068 startRule(context, 'Scenario_Definition');4069 startRule(context, 'Tags');4070 build(context, token);4071 return 11;4072 }4073 if(match_ScenarioLine(context, token)) {4074 endRule(context, 'Feature_Header');4075 startRule(context, 'Scenario_Definition');4076 startRule(context, 'Scenario');4077 build(context, token);4078 return 12;4079 }4080 if(match_ScenarioOutlineLine(context, token)) {4081 endRule(context, 'Feature_Header');4082 startRule(context, 'Scenario_Definition');4083 startRule(context, 'ScenarioOutline');4084 build(context, token);4085 return 17;4086 }4087 if(match_Other(context, token)) {4088 startRule(context, 'Description');4089 build(context, token);4090 return 4;4091 }4092 4093 var stateComment = "State: 3 - GherkinDocument:0>Feature:0>Feature_Header:2>#FeatureLine:0";4094 token.detach();4095 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4096 var error = token.isEof ?4097 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4098 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4099 if (self.stopAtFirstError) throw error;4100 addError(context, error);4101 return 3;4102 }4103 // GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:1>Description:0>#Other:04104 function matchTokenAt_4(token, context) {4105 if(match_EOF(context, token)) {4106 endRule(context, 'Description');4107 endRule(context, 'Feature_Header');4108 endRule(context, 'Feature');4109 build(context, token);4110 return 27;4111 }4112 if(match_Comment(context, token)) {4113 endRule(context, 'Description');4114 build(context, token);4115 return 5;4116 }4117 if(match_BackgroundLine(context, token)) {4118 endRule(context, 'Description');4119 endRule(context, 'Feature_Header');4120 startRule(context, 'Background');4121 build(context, token);4122 return 6;4123 }4124 if(match_TagLine(context, token)) {4125 endRule(context, 'Description');4126 endRule(context, 'Feature_Header');4127 startRule(context, 'Scenario_Definition');4128 startRule(context, 'Tags');4129 build(context, token);4130 return 11;4131 }4132 if(match_ScenarioLine(context, token)) {4133 endRule(context, 'Description');4134 endRule(context, 'Feature_Header');4135 startRule(context, 'Scenario_Definition');4136 startRule(context, 'Scenario');4137 build(context, token);4138 return 12;4139 }4140 if(match_ScenarioOutlineLine(context, token)) {4141 endRule(context, 'Description');4142 endRule(context, 'Feature_Header');4143 startRule(context, 'Scenario_Definition');4144 startRule(context, 'ScenarioOutline');4145 build(context, token);4146 return 17;4147 }4148 if(match_Other(context, token)) {4149 build(context, token);4150 return 4;4151 }4152 4153 var stateComment = "State: 4 - GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:1>Description:0>#Other:0";4154 token.detach();4155 var expectedTokens = ["#EOF", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4156 var error = token.isEof ?4157 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4158 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4159 if (self.stopAtFirstError) throw error;4160 addError(context, error);4161 return 4;4162 }4163 // GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:2>#Comment:04164 function matchTokenAt_5(token, context) {4165 if(match_EOF(context, token)) {4166 endRule(context, 'Feature_Header');4167 endRule(context, 'Feature');4168 build(context, token);4169 return 27;4170 }4171 if(match_Comment(context, token)) {4172 build(context, token);4173 return 5;4174 }4175 if(match_BackgroundLine(context, token)) {4176 endRule(context, 'Feature_Header');4177 startRule(context, 'Background');4178 build(context, token);4179 return 6;4180 }4181 if(match_TagLine(context, token)) {4182 endRule(context, 'Feature_Header');4183 startRule(context, 'Scenario_Definition');4184 startRule(context, 'Tags');4185 build(context, token);4186 return 11;4187 }4188 if(match_ScenarioLine(context, token)) {4189 endRule(context, 'Feature_Header');4190 startRule(context, 'Scenario_Definition');4191 startRule(context, 'Scenario');4192 build(context, token);4193 return 12;4194 }4195 if(match_ScenarioOutlineLine(context, token)) {4196 endRule(context, 'Feature_Header');4197 startRule(context, 'Scenario_Definition');4198 startRule(context, 'ScenarioOutline');4199 build(context, token);4200 return 17;4201 }4202 if(match_Empty(context, token)) {4203 build(context, token);4204 return 5;4205 }4206 4207 var stateComment = "State: 5 - GherkinDocument:0>Feature:0>Feature_Header:3>Description_Helper:2>#Comment:0";4208 token.detach();4209 var expectedTokens = ["#EOF", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Empty"];4210 var error = token.isEof ?4211 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4212 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4213 if (self.stopAtFirstError) throw error;4214 addError(context, error);4215 return 5;4216 }4217 // GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:04218 function matchTokenAt_6(token, context) {4219 if(match_EOF(context, token)) {4220 endRule(context, 'Background');4221 endRule(context, 'Feature');4222 build(context, token);4223 return 27;4224 }4225 if(match_Empty(context, token)) {4226 build(context, token);4227 return 6;4228 }4229 if(match_Comment(context, token)) {4230 build(context, token);4231 return 8;4232 }4233 if(match_StepLine(context, token)) {4234 startRule(context, 'Step');4235 build(context, token);4236 return 9;4237 }4238 if(match_TagLine(context, token)) {4239 endRule(context, 'Background');4240 startRule(context, 'Scenario_Definition');4241 startRule(context, 'Tags');4242 build(context, token);4243 return 11;4244 }4245 if(match_ScenarioLine(context, token)) {4246 endRule(context, 'Background');4247 startRule(context, 'Scenario_Definition');4248 startRule(context, 'Scenario');4249 build(context, token);4250 return 12;4251 }4252 if(match_ScenarioOutlineLine(context, token)) {4253 endRule(context, 'Background');4254 startRule(context, 'Scenario_Definition');4255 startRule(context, 'ScenarioOutline');4256 build(context, token);4257 return 17;4258 }4259 if(match_Other(context, token)) {4260 startRule(context, 'Description');4261 build(context, token);4262 return 7;4263 }4264 4265 var stateComment = "State: 6 - GherkinDocument:0>Feature:1>Background:0>#BackgroundLine:0";4266 token.detach();4267 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];4268 var error = token.isEof ?4269 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :4270 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);4271 if (self.stopAtFirstError) throw error;4272 addError(context, error);4273 return 6;4274 }4275 // GherkinDocument:0>Feature:1>Background:1>Description_Helper:1>Description:0>#Other:04276 function matchTokenAt_7(token, context) {4277 if(match_EOF(context, token)) {4278 endRule(context, 'Description');4279 endRule(context, 'Background');4280 endRule(context, 'Feature');4281 build(context, token);4282 return 27;4283 }4284 if(match_Comment(context, token)) {4285 endRule(context, 'Description');4286 build(context, token);4287 return 8;4288 }4289 if(match_StepLine(context, token)) {4290 endRule(context, 'Description');...
parser.js
Source:parser.js
...128 return matchTokenAt_5(token, context);129 case 6:130 return matchTokenAt_6(token, context);131 case 7:132 return matchTokenAt_7(token, context);133 case 8:134 return matchTokenAt_8(token, context);135 case 9:136 return matchTokenAt_9(token, context);137 case 10:138 return matchTokenAt_10(token, context);139 case 11:140 return matchTokenAt_11(token, context);141 case 12:142 return matchTokenAt_12(token, context);143 case 13:144 return matchTokenAt_13(token, context);145 case 14:146 return matchTokenAt_14(token, context);147 case 15:148 return matchTokenAt_15(token, context);149 case 16:150 return matchTokenAt_16(token, context);151 case 17:152 return matchTokenAt_17(token, context);153 case 18:154 return matchTokenAt_18(token, context);155 case 19:156 return matchTokenAt_19(token, context);157 case 20:158 return matchTokenAt_20(token, context);159 case 21:160 return matchTokenAt_21(token, context);161 case 22:162 return matchTokenAt_22(token, context);163 case 23:164 return matchTokenAt_23(token, context);165 case 24:166 return matchTokenAt_24(token, context);167 case 25:168 return matchTokenAt_25(token, context);169 case 26:170 return matchTokenAt_26(token, context);171 case 28:172 return matchTokenAt_28(token, context);173 case 29:174 return matchTokenAt_29(token, context);175 case 30:176 return matchTokenAt_30(token, context);177 case 31:178 return matchTokenAt_31(token, context);179 case 32:180 return matchTokenAt_32(token, context);181 case 33:182 return matchTokenAt_33(token, context);183 default:184 throw new Error("Unknown state: " + state);185 }186 }187 // Start188 function matchTokenAt_0(token, context) {189 if(match_Language(context, token)) {190 startRule(context, 'Feature_Header');191 build(context, token);192 return 1;193 }194 if(match_TagLine(context, token)) {195 startRule(context, 'Feature_Header');196 startRule(context, 'Tags');197 build(context, token);198 return 2;199 }200 if(match_FeatureLine(context, token)) {201 startRule(context, 'Feature_Header');202 build(context, token);203 return 3;204 }205 if(match_Comment(context, token)) {206 build(context, token);207 return 0;208 }209 if(match_Empty(context, token)) {210 build(context, token);211 return 0;212 }213 214 var stateComment = "State: 0 - Start";215 token.detach();216 var expectedTokens = ["#Language", "#TagLine", "#FeatureLine", "#Comment", "#Empty"];217 var error = token.isEof ?218 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :219 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);220 if (this.stopAtFirstError) throw error;221 addError(context, error);222 return 0;223 }224 // Feature:0>Feature_Header:0>#Language:0225 function matchTokenAt_1(token, context) {226 if(match_TagLine(context, token)) {227 startRule(context, 'Tags');228 build(context, token);229 return 2;230 }231 if(match_FeatureLine(context, token)) {232 build(context, token);233 return 3;234 }235 if(match_Comment(context, token)) {236 build(context, token);237 return 1;238 }239 if(match_Empty(context, token)) {240 build(context, token);241 return 1;242 }243 244 var stateComment = "State: 1 - Feature:0>Feature_Header:0>#Language:0";245 token.detach();246 var expectedTokens = ["#TagLine", "#FeatureLine", "#Comment", "#Empty"];247 var error = token.isEof ?248 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :249 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);250 if (this.stopAtFirstError) throw error;251 addError(context, error);252 return 1;253 }254 // Feature:0>Feature_Header:1>Tags:0>#TagLine:0255 function matchTokenAt_2(token, context) {256 if(match_TagLine(context, token)) {257 build(context, token);258 return 2;259 }260 if(match_FeatureLine(context, token)) {261 endRule(context, 'Tags');262 build(context, token);263 return 3;264 }265 if(match_Comment(context, token)) {266 build(context, token);267 return 2;268 }269 if(match_Empty(context, token)) {270 build(context, token);271 return 2;272 }273 274 var stateComment = "State: 2 - Feature:0>Feature_Header:1>Tags:0>#TagLine:0";275 token.detach();276 var expectedTokens = ["#TagLine", "#FeatureLine", "#Comment", "#Empty"];277 var error = token.isEof ?278 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :279 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);280 if (this.stopAtFirstError) throw error;281 addError(context, error);282 return 2;283 }284 // Feature:0>Feature_Header:2>#FeatureLine:0285 function matchTokenAt_3(token, context) {286 if(match_EOF(context, token)) {287 endRule(context, 'Feature_Header');288 build(context, token);289 return 27;290 }291 if(match_Empty(context, token)) {292 build(context, token);293 return 3;294 }295 if(match_Comment(context, token)) {296 build(context, token);297 return 5;298 }299 if(match_BackgroundLine(context, token)) {300 endRule(context, 'Feature_Header');301 startRule(context, 'Background');302 build(context, token);303 return 6;304 }305 if(match_TagLine(context, token)) {306 endRule(context, 'Feature_Header');307 startRule(context, 'Scenario_Definition');308 startRule(context, 'Tags');309 build(context, token);310 return 11;311 }312 if(match_ScenarioLine(context, token)) {313 endRule(context, 'Feature_Header');314 startRule(context, 'Scenario_Definition');315 startRule(context, 'Scenario');316 build(context, token);317 return 12;318 }319 if(match_ScenarioOutlineLine(context, token)) {320 endRule(context, 'Feature_Header');321 startRule(context, 'Scenario_Definition');322 startRule(context, 'ScenarioOutline');323 build(context, token);324 return 17;325 }326 if(match_Other(context, token)) {327 startRule(context, 'Description');328 build(context, token);329 return 4;330 }331 332 var stateComment = "State: 3 - Feature:0>Feature_Header:2>#FeatureLine:0";333 token.detach();334 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];335 var error = token.isEof ?336 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :337 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);338 if (this.stopAtFirstError) throw error;339 addError(context, error);340 return 3;341 }342 // Feature:0>Feature_Header:3>Feature_Description:0>Description_Helper:1>Description:0>#Other:0343 function matchTokenAt_4(token, context) {344 if(match_EOF(context, token)) {345 endRule(context, 'Description');346 endRule(context, 'Feature_Header');347 build(context, token);348 return 27;349 }350 if(match_Comment(context, token)) {351 endRule(context, 'Description');352 build(context, token);353 return 5;354 }355 if(match_BackgroundLine(context, token)) {356 endRule(context, 'Description');357 endRule(context, 'Feature_Header');358 startRule(context, 'Background');359 build(context, token);360 return 6;361 }362 if(match_TagLine(context, token)) {363 endRule(context, 'Description');364 endRule(context, 'Feature_Header');365 startRule(context, 'Scenario_Definition');366 startRule(context, 'Tags');367 build(context, token);368 return 11;369 }370 if(match_ScenarioLine(context, token)) {371 endRule(context, 'Description');372 endRule(context, 'Feature_Header');373 startRule(context, 'Scenario_Definition');374 startRule(context, 'Scenario');375 build(context, token);376 return 12;377 }378 if(match_ScenarioOutlineLine(context, token)) {379 endRule(context, 'Description');380 endRule(context, 'Feature_Header');381 startRule(context, 'Scenario_Definition');382 startRule(context, 'ScenarioOutline');383 build(context, token);384 return 17;385 }386 if(match_Other(context, token)) {387 build(context, token);388 return 4;389 }390 391 var stateComment = "State: 4 - Feature:0>Feature_Header:3>Feature_Description:0>Description_Helper:1>Description:0>#Other:0";392 token.detach();393 var expectedTokens = ["#EOF", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];394 var error = token.isEof ?395 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :396 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);397 if (this.stopAtFirstError) throw error;398 addError(context, error);399 return 4;400 }401 // Feature:0>Feature_Header:3>Feature_Description:0>Description_Helper:2>#Comment:0402 function matchTokenAt_5(token, context) {403 if(match_EOF(context, token)) {404 endRule(context, 'Feature_Header');405 build(context, token);406 return 27;407 }408 if(match_Comment(context, token)) {409 build(context, token);410 return 5;411 }412 if(match_BackgroundLine(context, token)) {413 endRule(context, 'Feature_Header');414 startRule(context, 'Background');415 build(context, token);416 return 6;417 }418 if(match_TagLine(context, token)) {419 endRule(context, 'Feature_Header');420 startRule(context, 'Scenario_Definition');421 startRule(context, 'Tags');422 build(context, token);423 return 11;424 }425 if(match_ScenarioLine(context, token)) {426 endRule(context, 'Feature_Header');427 startRule(context, 'Scenario_Definition');428 startRule(context, 'Scenario');429 build(context, token);430 return 12;431 }432 if(match_ScenarioOutlineLine(context, token)) {433 endRule(context, 'Feature_Header');434 startRule(context, 'Scenario_Definition');435 startRule(context, 'ScenarioOutline');436 build(context, token);437 return 17;438 }439 if(match_Empty(context, token)) {440 build(context, token);441 return 5;442 }443 444 var stateComment = "State: 5 - Feature:0>Feature_Header:3>Feature_Description:0>Description_Helper:2>#Comment:0";445 token.detach();446 var expectedTokens = ["#EOF", "#Comment", "#BackgroundLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Empty"];447 var error = token.isEof ?448 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :449 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);450 if (this.stopAtFirstError) throw error;451 addError(context, error);452 return 5;453 }454 // Feature:1>Background:0>#BackgroundLine:0455 function matchTokenAt_6(token, context) {456 if(match_EOF(context, token)) {457 endRule(context, 'Background');458 build(context, token);459 return 27;460 }461 if(match_Empty(context, token)) {462 build(context, token);463 return 6;464 }465 if(match_Comment(context, token)) {466 build(context, token);467 return 8;468 }469 if(match_StepLine(context, token)) {470 startRule(context, 'Step');471 build(context, token);472 return 9;473 }474 if(match_TagLine(context, token)) {475 endRule(context, 'Background');476 startRule(context, 'Scenario_Definition');477 startRule(context, 'Tags');478 build(context, token);479 return 11;480 }481 if(match_ScenarioLine(context, token)) {482 endRule(context, 'Background');483 startRule(context, 'Scenario_Definition');484 startRule(context, 'Scenario');485 build(context, token);486 return 12;487 }488 if(match_ScenarioOutlineLine(context, token)) {489 endRule(context, 'Background');490 startRule(context, 'Scenario_Definition');491 startRule(context, 'ScenarioOutline');492 build(context, token);493 return 17;494 }495 if(match_Other(context, token)) {496 startRule(context, 'Description');497 build(context, token);498 return 7;499 }500 501 var stateComment = "State: 6 - Feature:1>Background:0>#BackgroundLine:0";502 token.detach();503 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#ScenarioOutlineLine", "#Other"];504 var error = token.isEof ?505 new Errors.UnexpectedEOFException(token, expectedTokens, stateComment) :506 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);507 if (this.stopAtFirstError) throw error;508 addError(context, error);509 return 6;510 }511 // Feature:1>Background:1>Background_Description:0>Description_Helper:1>Description:0>#Other:0512 function matchTokenAt_7(token, context) {513 if(match_EOF(context, token)) {514 endRule(context, 'Description');515 endRule(context, 'Background');516 build(context, token);517 return 27;518 }519 if(match_Comment(context, token)) {520 endRule(context, 'Description');521 build(context, token);522 return 8;523 }524 if(match_StepLine(context, token)) {525 endRule(context, 'Description');526 startRule(context, 'Step');...
Using AI Code Generation
1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var lexer = new gherkin.Lexer('en');4var gherkinDocument = parser.parse(gherkinSource);5var feature = gherkinDocument.feature;6var scenarios = feature.children.filter(function(child) {7 return child.type === 'Scenario';8});9var scenario = scenarios[0];10var steps = scenario.steps;11var step = steps[0];12var token = step.keywordToken;13var match = lexer.matchTokenAt_7(token.line, token.column);14console.log(match);15{ line: 4,16 matchedKeyword: 'Given' }17var gherkin = require('gherkin');18var parser = new gherkin.Parser();19var lexer = new gherkin.Lexer('en');20var gherkinDocument = parser.parse(gherkinSource);21var feature = gherkinDocument.feature;22var scenarios = feature.children.filter(function(child) {23 return child.type === 'Scenario';24});25var scenario = scenarios[0];26var steps = scenario.steps;27var step = steps[0];28var token = step.textToken;29var match = lexer.matchTokenAt_8(token.line, token.column);30console.log(match);31{ line: 5,32 matchedKeyword: 'I have a gherkin string' }33var gherkin = require('gherkin');34var parser = new gherkin.Parser();35var lexer = new gherkin.Lexer('en');36var gherkinDocument = parser.parse(gherkinSource);37var feature = gherkinDocument.feature;38var scenarios = feature.children.filter(function(child) {39 return child.type === 'Scenario';40});41var scenario = scenarios[0];42var steps = scenario.steps;43var step = steps[0];
Using AI Code Generation
1var gherkin = require('./node_modules/cucumber/node_modules/gherkin/lib/gherkin');2var lexer = new gherkin.Lexer('en');3var tokenMatcher = new gherkin.TokenMatcher();4var token = tokenMatcher.matchTokenAt_7(lexer.lex("Feature: test"), 0);5console.log(token);6console.log(tokenMatcher.matchTokenAt_7(lexer.lex("Scenario: test"), 0));7console.log(tokenMatcher.matchTokenAt_7(lexer.lex("Given test"), 0));8console.log(tokenMatcher.matchTokenAt_7(lexer.lex("When test"), 0));9console.log(tokenMatcher.matchTokenAt_7(lexer.lex("Then test"), 0));10console.log(tokenMatcher.matchTokenAt_7(lexer.lex("And test"), 0));11console.log(tokenMatcher.matchTokenAt_7(lexer.lex("But test"), 0));12console.log(tokenMatcher.matchTokenAt_7(lexer.lex("Examples:"), 0));13console.log(tokenMatcher.matchTokenAt_7(lexer.lex("|test1|"), 0));14console.log(tokenMatcher.matchTokenAt_7(lexer.lex("|test2|"), 0));15console.log(tokenMatcher.matchTokenAt_7(lexer.lex("|test3|"), 0));16{line: 1,17 location: {line: 1, column: 1},18 matchedIndent: 0}19{line: 1,20 location: {line: 1, column: 1},21 matchedIndent: 0}22{line: 1,23 location: {line: 1, column: 1},24 matchedIndent: 0}25{line: 1,26 location: {line: 1, column: 1},
Using AI Code Generation
1var Cucumber = require('cucumber');2var fs = require('fs');3var gherkin = require('cucumber/lib/gherkin');4var lexer = new gherkin.Lexer('en');5var feature = fs.readFileSync('features/test.feature', 'utf8');6var tokens = lexer.lex(feature);7var token = tokens[0];8console.log(token.matchTokenAt_7(5, 'FeatureLine'));
Using AI Code Generation
1var Cucumber = require("cucumber-gherkin");2var fs = require("fs");3var file = fs.readFileSync("test.feature", "utf-8");4var lexer = new Cucumber.Lexer("en");5var tokenMatcher = new Cucumber.TokenMatcher();6var token = lexer.matchTokenAt_7(file, 0, tokenMatcher, function (arg0) {7 return arg0;8});9console.log(token);10var Cucumber = require("cucumber-gherkin");11var fs = require("fs");12var file = fs.readFileSync("test.feature", "utf-8");13var lexer = new Cucumber.Lexer("en");14var tokenMatcher = new Cucumber.TokenMatcher();15var token = lexer.matchTokenAt_8(file, 0, tokenMatcher, function (arg0) {16 return arg0;17});18console.log(token);19var Cucumber = require("cucumber-gherkin");20var fs = require("fs");21var file = fs.readFileSync("test.feature", "utf-8");22var lexer = new Cucumber.Lexer("en");23var tokenMatcher = new Cucumber.TokenMatcher();24var token = lexer.matchTokenAt_9(file, 0, tokenMatcher, function (arg0) {25 return arg0;26});27console.log(token);
Using AI Code Generation
1var gherkin = require('cucumber-gherkin');2var tokenMatcher = new gherkin.TokenMatcher();3var token = new gherkin.Token('feature', 'Feature', 1);4var feature = tokenMatcher.matchTokenAt_7(token, 0, 0);5console.log(feature);6var gherkin = require('cucumber-gherkin');7var tokenMatcher = new gherkin.TokenMatcher();8var token = new gherkin.Token('feature', 'Feature', 1);9var feature = tokenMatcher.matchTokenAt_8(token, 0, 0);10console.log(feature);11var gherkin = require('cucumber-gherkin');12var tokenMatcher = new gherkin.TokenMatcher();13var token = new gherkin.Token('feature', 'Feature', 1);14var feature = tokenMatcher.matchTokenAt_9(token, 0, 0);15console.log(feature);16var gherkin = require('cucumber-gherkin');17var tokenMatcher = new gherkin.TokenMatcher();18var token = new gherkin.Token('feature', 'Feature', 1);19var feature = tokenMatcher.matchTokenAt_10(token, 0, 0);20console.log(feature);21var gherkin = require('cucumber-gherkin');22var tokenMatcher = new gherkin.TokenMatcher();23var token = new gherkin.Token('feature', 'Feature', 1);24var feature = tokenMatcher.matchTokenAt_11(token, 0, 0);25console.log(feature);26var gherkin = require('cucumber-gherkin');27var tokenMatcher = new gherkin.TokenMatcher();28var token = new gherkin.Token('feature', 'Feature', 1);29var feature = tokenMatcher.matchTokenAt_12(token, 0, 0);30console.log(feature);
Using AI Code Generation
1var path = require('path');2var gherkin = require('gherkin');3var parser = new gherkin.Parser();4var lexer = new gherkin.Lexer();5var tokenMatcher = new gherkin.TokenMatcher();6var gherkinDocument = parser.parse(lexer.lex('Feature: test7'));8var token = gherkinDocument.feature.children[0].steps[0].keywordToken;9var matched = tokenMatcher.matchTokenAt_7(token, 0, 'Given ');10console.log('matched: ' + matched);11(function (exports, require, module, __filename, __dirname) { (function() {12 at Object.<anonymous> (C:\Users\user\AppData\Roaming13 at Module._compile (module.js:456:26)14 at Object..js (module.js:474:10)15 at Module.load (module.js:356:32)16 at Function.Module._load (module.js:312:12)17 at Module.require (module.js:364:17)18 at require (module.js:380:17)19 at Object.<anonymous> (C:\Users\user\AppData\Roaming20 at Module._compile (module.js:456:26)21 at Object..js (module.js:474:10)22var gherkin = require('gherkin');23var parser = new gherkin.Parser();24var lexer = new gherkin.Lexer();
Using AI Code Generation
1var gherkin = require('gherkin');2var parser = new gherkin.Parser();3var feature = parser.parse('Feature: test4');5var tokenMatcher = new gherkin.TokenMatcher();6var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 0);7console.log(token.type);8console.log(token.data);9var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 1);10console.log(token.type);11console.log(token.data);12var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 2);13console.log(token.type);14console.log(token.data);15var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 3);16console.log(token.type);17console.log(token.data);18var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 4);19console.log(token.type);20console.log(token.data);21var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 5);22console.log(token.type);23console.log(token.data);24var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 6);25console.log(token.type);26console.log(token.data);27var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 7);28console.log(token.type);29console.log(token.data);30var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 8);31console.log(token.type);32console.log(token.data);33var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 9);34console.log(token.type);35console.log(token.data);36var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 10);37console.log(token.type);38console.log(token.data);39var token = tokenMatcher.matchTokenAt_7(feature.scenarioDefinitions[0].steps[0].keyword, 11);40console.log(token.type);41console.log(token.data);
LambdaTest offers a detailed Cucumber testing tutorial, explaining its features, importance, best practices, and more to help you get started with running your automation testing scripts.
Here are the detailed Cucumber testing chapters to help you get started:
Get 100 minutes of automation test minutes FREE!!