How to use CompositeParserException method in Cucumber-gherkin

Best JavaScript code snippet using cucumber-gherkin

gherkin.js

Source:gherkin.js Github

copy

Full Screen

...329 Errors[name] = ErrorProto;330});331Errors.CompositeParserException.create = function(errors) {332 var message = "Parser errors:\n" + errors.map(function (e) { return e.message; }).join("\n");333 var err = new Errors.CompositeParserException(message);334 err.errors = errors;335 return err;336};337Errors.UnexpectedTokenException.create = function(token, expectedTokenTypes, stateComment) {338 var message = "expected: " + expectedTokenTypes.join(', ') + ", got '" + token.getTokenValue().trim() + "'";339 var location = !token.location.column340 ? {line: token.location.line, column: token.line.indent + 1 }341 : token.location;342 return createError(Errors.UnexpectedEOFException, message, location);343};344Errors.UnexpectedEOFException.create = function(token, expectedTokenTypes, stateComment) {345 var message = "unexpected end of file, expected: " + expectedTokenTypes.join(', ');346 return createError(Errors.UnexpectedTokenException, message, token.location);347};...

Full Screen

Full Screen

parser.js

Source:parser.js Github

copy

Full Screen

1// This file is generated. Do not edit! Edit gherkin-javascript.razor instead.2var Errors = require('./errors');3var AstBuilder = require('./ast_builder');4var TokenScanner = require('./token_scanner');5var TokenMatcher = require('./token_matcher');6var RULE_TYPES = [7 'None',8 '_EOF', // #EOF9 '_Empty', // #Empty10 '_Comment', // #Comment11 '_TagLine', // #TagLine12 '_ScenarioLine', // #ScenarioLine13 '_ExamplesLine', // #ExamplesLine14 '_StepLine', // #StepLine15 '_DocStringSeparator', // #DocStringSeparator16 '_TableRow', // #TableRow17 '_Language', // #Language18 '_Other', // #Other19 'GherkinDocument', // GherkinDocument! := Scenario_Definition*20 'Scenario_Definition', // Scenario_Definition! := Tags? Scenario21 'Scenario', // Scenario! := #ScenarioLine Scenario_Description Scenario_Step*22 'Scenario_Step', // Scenario_Step := Step23 'Step', // Step! := #StepLine Step_Arg?24 'Step_Arg', // Step_Arg := (DataTable | DocString)25 'DataTable', // DataTable! := #TableRow+26 'DocString', // DocString! := #DocStringSeparator #Other* #DocStringSeparator27 'Tags', // Tags! := #TagLine+28 'Scenario_Description', // Scenario_Description := Description_Helper29 'Description_Helper', // Description_Helper := #Empty* Description? #Comment*30 'Description', // Description! := #Other+31];32module.exports = function Parser(builder) {33 builder = builder || new AstBuilder();34 var self = this;35 var context;36 this.parse = function(tokenScanner, tokenMatcher) {37 if(typeof tokenScanner == 'string') {38 tokenScanner = new TokenScanner(tokenScanner);39 }40 tokenMatcher = tokenMatcher || new TokenMatcher();41 builder.reset();42 tokenMatcher.reset();43 context = {44 tokenScanner: tokenScanner,45 tokenMatcher: tokenMatcher,46 tokenQueue: [],47 errors: []48 };49 startRule(context, "GherkinDocument");50 var state = 0;51 var token = null;52 while(true) {53 token = readToken(context);54 state = matchToken(state, token, context);55 if(token.isEof) break;56 }57 endRule(context, "GherkinDocument");58 if(context.errors.length > 0) {59 throw Errors.CompositeParserException.create(context.errors);60 }61 return getResult();62 };63 function addError(context, error) {64 context.errors.push(error);65 if (context.errors.length > 10)66 throw Errors.CompositeParserException.create(context.errors);67 }68 function startRule(context, ruleType) {69 handleAstError(context, function () {70 builder.startRule(ruleType);71 });72 }73 function endRule(context, ruleType) {74 handleAstError(context, function () {75 builder.endRule(ruleType);76 });77 }78 function build(context, token) {79 handleAstError(context, function () {80 builder.build(token);81 });82 }83 function getResult() {84 return builder.getResult();85 }86 function handleAstError(context, action) {87 handleExternalError(context, true, action)88 }89 function handleExternalError(context, defaultValue, action) {90 if(self.stopAtFirstError) return action();91 try {92 return action();93 } catch (e) {94 if(e instanceof Errors.CompositeParserException) {95 e.errors.forEach(function (error) {96 addError(context, error);97 });98 } else if(99 e instanceof Errors.ParserException ||100 e instanceof Errors.AstBuilderException ||101 e instanceof Errors.UnexpectedTokenException ||102 e instanceof Errors.NoSuchLanguageException103 ) {104 addError(context, e);105 } else {106 throw e;107 }108 }109 return defaultValue;110 }111 function readToken(context) {112 return context.tokenQueue.length > 0 ?113 context.tokenQueue.shift() :114 context.tokenScanner.read();115 }116 function matchToken(state, token, context) {117 switch(state) {118 case 0:119 return matchTokenAt_0(token, context);120 case 1:121 return matchTokenAt_1(token, context);122 case 2:123 return matchTokenAt_2(token, context);124 case 3:125 return matchTokenAt_3(token, context);126 case 4:127 return matchTokenAt_4(token, context);128 case 5:129 return matchTokenAt_5(token, context);130 case 6:131 return matchTokenAt_6(token, context);132 case 8:133 return matchTokenAt_8(token, context);134 case 9:135 return matchTokenAt_9(token, context);136 default:137 throw new Error("Unknown state: " + state);138 }139 }140 // Start141 function matchTokenAt_0(token, context) {142 if(match_EOF(context, token)) {143 build(context, token);144 return 7;145 }146 if(match_TagLine(context, token)) {147 startRule(context, 'Scenario_Definition');148 startRule(context, 'Tags');149 build(context, token);150 return 1;151 }152 if(match_ScenarioLine(context, token)) {153 startRule(context, 'Scenario_Definition');154 startRule(context, 'Scenario');155 build(context, token);156 return 2;157 }158 if(match_Comment(context, token)) {159 build(context, token);160 return 0;161 }162 if(match_Empty(context, token)) {163 build(context, token);164 return 0;165 }166 167 var stateComment = "State: 0 - Start";168 token.detach();169 var expectedTokens = ["#EOF", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];170 var error = token.isEof ?171 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :172 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);173 if (self.stopAtFirstError) throw error;174 addError(context, error);175 return 0;176 }177 // GherkinDocument:0>Scenario_Definition:0>Tags:0>#TagLine:0178 function matchTokenAt_1(token, context) {179 if(match_TagLine(context, token)) {180 build(context, token);181 return 1;182 }183 if(match_ScenarioLine(context, token)) {184 endRule(context, 'Tags');185 startRule(context, 'Scenario');186 build(context, token);187 return 2;188 }189 if(match_Comment(context, token)) {190 build(context, token);191 return 1;192 }193 if(match_Empty(context, token)) {194 build(context, token);195 return 1;196 }197 198 var stateComment = "State: 1 - GherkinDocument:0>Scenario_Definition:0>Tags:0>#TagLine:0";199 token.detach();200 var expectedTokens = ["#TagLine", "#ScenarioLine", "#Comment", "#Empty"];201 var error = token.isEof ?202 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :203 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);204 if (self.stopAtFirstError) throw error;205 addError(context, error);206 return 1;207 }208 // GherkinDocument:0>Scenario_Definition:1>Scenario:0>#ScenarioLine:0209 function matchTokenAt_2(token, context) {210 if(match_EOF(context, token)) {211 endRule(context, 'Scenario');212 endRule(context, 'Scenario_Definition');213 build(context, token);214 return 7;215 }216 if(match_Empty(context, token)) {217 build(context, token);218 return 2;219 }220 if(match_Comment(context, token)) {221 build(context, token);222 return 4;223 }224 if(match_StepLine(context, token)) {225 startRule(context, 'Step');226 build(context, token);227 return 5;228 }229 if(match_TagLine(context, token)) {230 endRule(context, 'Scenario');231 endRule(context, 'Scenario_Definition');232 startRule(context, 'Scenario_Definition');233 startRule(context, 'Tags');234 build(context, token);235 return 1;236 }237 if(match_ScenarioLine(context, token)) {238 endRule(context, 'Scenario');239 endRule(context, 'Scenario_Definition');240 startRule(context, 'Scenario_Definition');241 startRule(context, 'Scenario');242 build(context, token);243 return 2;244 }245 if(match_Other(context, token)) {246 startRule(context, 'Description');247 build(context, token);248 return 3;249 }250 251 var stateComment = "State: 2 - GherkinDocument:0>Scenario_Definition:1>Scenario:0>#ScenarioLine:0";252 token.detach();253 var expectedTokens = ["#EOF", "#Empty", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#Other"];254 var error = token.isEof ?255 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :256 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);257 if (self.stopAtFirstError) throw error;258 addError(context, error);259 return 2;260 }261 // GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:1>Description:0>#Other:0262 function matchTokenAt_3(token, context) {263 if(match_EOF(context, token)) {264 endRule(context, 'Description');265 endRule(context, 'Scenario');266 endRule(context, 'Scenario_Definition');267 build(context, token);268 return 7;269 }270 if(match_Comment(context, token)) {271 endRule(context, 'Description');272 build(context, token);273 return 4;274 }275 if(match_StepLine(context, token)) {276 endRule(context, 'Description');277 startRule(context, 'Step');278 build(context, token);279 return 5;280 }281 if(match_TagLine(context, token)) {282 endRule(context, 'Description');283 endRule(context, 'Scenario');284 endRule(context, 'Scenario_Definition');285 startRule(context, 'Scenario_Definition');286 startRule(context, 'Tags');287 build(context, token);288 return 1;289 }290 if(match_ScenarioLine(context, token)) {291 endRule(context, 'Description');292 endRule(context, 'Scenario');293 endRule(context, 'Scenario_Definition');294 startRule(context, 'Scenario_Definition');295 startRule(context, 'Scenario');296 build(context, token);297 return 2;298 }299 if(match_Other(context, token)) {300 build(context, token);301 return 3;302 }303 304 var stateComment = "State: 3 - GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:1>Description:0>#Other:0";305 token.detach();306 var expectedTokens = ["#EOF", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#Other"];307 var error = token.isEof ?308 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :309 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);310 if (self.stopAtFirstError) throw error;311 addError(context, error);312 return 3;313 }314 // GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:2>#Comment:0315 function matchTokenAt_4(token, context) {316 if(match_EOF(context, token)) {317 endRule(context, 'Scenario');318 endRule(context, 'Scenario_Definition');319 build(context, token);320 return 7;321 }322 if(match_Comment(context, token)) {323 build(context, token);324 return 4;325 }326 if(match_StepLine(context, token)) {327 startRule(context, 'Step');328 build(context, token);329 return 5;330 }331 if(match_TagLine(context, token)) {332 endRule(context, 'Scenario');333 endRule(context, 'Scenario_Definition');334 startRule(context, 'Scenario_Definition');335 startRule(context, 'Tags');336 build(context, token);337 return 1;338 }339 if(match_ScenarioLine(context, token)) {340 endRule(context, 'Scenario');341 endRule(context, 'Scenario_Definition');342 startRule(context, 'Scenario_Definition');343 startRule(context, 'Scenario');344 build(context, token);345 return 2;346 }347 if(match_Empty(context, token)) {348 build(context, token);349 return 4;350 }351 352 var stateComment = "State: 4 - GherkinDocument:0>Scenario_Definition:1>Scenario:1>Scenario_Description:0>Description_Helper:2>#Comment:0";353 token.detach();354 var expectedTokens = ["#EOF", "#Comment", "#StepLine", "#TagLine", "#ScenarioLine", "#Empty"];355 var error = token.isEof ?356 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :357 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);358 if (self.stopAtFirstError) throw error;359 addError(context, error);360 return 4;361 }362 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:0>#StepLine:0363 function matchTokenAt_5(token, context) {364 if(match_EOF(context, token)) {365 endRule(context, 'Step');366 endRule(context, 'Scenario');367 endRule(context, 'Scenario_Definition');368 build(context, token);369 return 7;370 }371 if(match_TableRow(context, token)) {372 startRule(context, 'DataTable');373 build(context, token);374 return 6;375 }376 if(match_DocStringSeparator(context, token)) {377 startRule(context, 'DocString');378 build(context, token);379 return 8;380 }381 if(match_StepLine(context, token)) {382 endRule(context, 'Step');383 startRule(context, 'Step');384 build(context, token);385 return 5;386 }387 if(match_TagLine(context, token)) {388 endRule(context, 'Step');389 endRule(context, 'Scenario');390 endRule(context, 'Scenario_Definition');391 startRule(context, 'Scenario_Definition');392 startRule(context, 'Tags');393 build(context, token);394 return 1;395 }396 if(match_ScenarioLine(context, token)) {397 endRule(context, 'Step');398 endRule(context, 'Scenario');399 endRule(context, 'Scenario_Definition');400 startRule(context, 'Scenario_Definition');401 startRule(context, 'Scenario');402 build(context, token);403 return 2;404 }405 if(match_Comment(context, token)) {406 build(context, token);407 return 5;408 }409 if(match_Empty(context, token)) {410 build(context, token);411 return 5;412 }413 414 var stateComment = "State: 5 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:0>#StepLine:0";415 token.detach();416 var expectedTokens = ["#EOF", "#TableRow", "#DocStringSeparator", "#StepLine", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];417 var error = token.isEof ?418 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :419 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);420 if (self.stopAtFirstError) throw error;421 addError(context, error);422 return 5;423 }424 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:0>DataTable:0>#TableRow:0425 function matchTokenAt_6(token, context) {426 if(match_EOF(context, token)) {427 endRule(context, 'DataTable');428 endRule(context, 'Step');429 endRule(context, 'Scenario');430 endRule(context, 'Scenario_Definition');431 build(context, token);432 return 7;433 }434 if(match_TableRow(context, token)) {435 build(context, token);436 return 6;437 }438 if(match_StepLine(context, token)) {439 endRule(context, 'DataTable');440 endRule(context, 'Step');441 startRule(context, 'Step');442 build(context, token);443 return 5;444 }445 if(match_TagLine(context, token)) {446 endRule(context, 'DataTable');447 endRule(context, 'Step');448 endRule(context, 'Scenario');449 endRule(context, 'Scenario_Definition');450 startRule(context, 'Scenario_Definition');451 startRule(context, 'Tags');452 build(context, token);453 return 1;454 }455 if(match_ScenarioLine(context, token)) {456 endRule(context, 'DataTable');457 endRule(context, 'Step');458 endRule(context, 'Scenario');459 endRule(context, 'Scenario_Definition');460 startRule(context, 'Scenario_Definition');461 startRule(context, 'Scenario');462 build(context, token);463 return 2;464 }465 if(match_Comment(context, token)) {466 build(context, token);467 return 6;468 }469 if(match_Empty(context, token)) {470 build(context, token);471 return 6;472 }473 474 var stateComment = "State: 6 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:0>DataTable:0>#TableRow:0";475 token.detach();476 var expectedTokens = ["#EOF", "#TableRow", "#StepLine", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];477 var error = token.isEof ?478 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :479 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);480 if (self.stopAtFirstError) throw error;481 addError(context, error);482 return 6;483 }484 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:0>#DocStringSeparator:0485 function matchTokenAt_8(token, context) {486 if(match_DocStringSeparator(context, token)) {487 build(context, token);488 return 9;489 }490 if(match_Other(context, token)) {491 build(context, token);492 return 8;493 }494 495 var stateComment = "State: 8 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:0>#DocStringSeparator:0";496 token.detach();497 var expectedTokens = ["#DocStringSeparator", "#Other"];498 var error = token.isEof ?499 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :500 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);501 if (self.stopAtFirstError) throw error;502 addError(context, error);503 return 8;504 }505 // GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:2>#DocStringSeparator:0506 function matchTokenAt_9(token, context) {507 if(match_EOF(context, token)) {508 endRule(context, 'DocString');509 endRule(context, 'Step');510 endRule(context, 'Scenario');511 endRule(context, 'Scenario_Definition');512 build(context, token);513 return 7;514 }515 if(match_StepLine(context, token)) {516 endRule(context, 'DocString');517 endRule(context, 'Step');518 startRule(context, 'Step');519 build(context, token);520 return 5;521 }522 if(match_TagLine(context, token)) {523 endRule(context, 'DocString');524 endRule(context, 'Step');525 endRule(context, 'Scenario');526 endRule(context, 'Scenario_Definition');527 startRule(context, 'Scenario_Definition');528 startRule(context, 'Tags');529 build(context, token);530 return 1;531 }532 if(match_ScenarioLine(context, token)) {533 endRule(context, 'DocString');534 endRule(context, 'Step');535 endRule(context, 'Scenario');536 endRule(context, 'Scenario_Definition');537 startRule(context, 'Scenario_Definition');538 startRule(context, 'Scenario');539 build(context, token);540 return 2;541 }542 if(match_Comment(context, token)) {543 build(context, token);544 return 9;545 }546 if(match_Empty(context, token)) {547 build(context, token);548 return 9;549 }550 551 var stateComment = "State: 9 - GherkinDocument:0>Scenario_Definition:1>Scenario:2>Scenario_Step:0>Step:1>Step_Arg:0>__alt0:1>DocString:2>#DocStringSeparator:0";552 token.detach();553 var expectedTokens = ["#EOF", "#StepLine", "#TagLine", "#ScenarioLine", "#Comment", "#Empty"];554 var error = token.isEof ?555 Errors.UnexpectedEOFException.create(token, expectedTokens, stateComment) :556 Errors.UnexpectedTokenException.create(token, expectedTokens, stateComment);557 if (self.stopAtFirstError) throw error;558 addError(context, error);559 return 9;560 }561 function match_EOF(context, token) {562 return handleExternalError(context, false, function () {563 return context.tokenMatcher.match_EOF(token);564 });565 }566 function match_Empty(context, token) {567 if(token.isEof) return false;568 return handleExternalError(context, false, function () {569 return context.tokenMatcher.match_Empty(token);570 });571 }572 function match_Comment(context, token) {573 if(token.isEof) return false;574 return handleExternalError(context, false, function () {575 return context.tokenMatcher.match_Comment(token);576 });577 }578 function match_TagLine(context, token) {579 if(token.isEof) return false;580 return handleExternalError(context, false, function () {581 return context.tokenMatcher.match_TagLine(token);582 });583 }584 function match_ScenarioLine(context, token) {585 if(token.isEof) return false;586 return handleExternalError(context, false, function () {587 return context.tokenMatcher.match_ScenarioLine(token);588 });589 }590 function match_ExamplesLine(context, token) {591 if(token.isEof) return false;592 return handleExternalError(context, false, function () {593 return context.tokenMatcher.match_ExamplesLine(token);594 });595 }596 function match_StepLine(context, token) {597 if(token.isEof) return false;598 return handleExternalError(context, false, function () {599 return context.tokenMatcher.match_StepLine(token);600 });601 }602 function match_DocStringSeparator(context, token) {603 if(token.isEof) return false;604 return handleExternalError(context, false, function () {605 return context.tokenMatcher.match_DocStringSeparator(token);606 });607 }608 function match_TableRow(context, token) {609 if(token.isEof) return false;610 return handleExternalError(context, false, function () {611 return context.tokenMatcher.match_TableRow(token);612 });613 }614 function match_Language(context, token) {615 if(token.isEof) return false;616 return handleExternalError(context, false, function () {617 return context.tokenMatcher.match_Language(token);618 });619 }620 function match_Other(context, token) {621 if(token.isEof) return false;622 return handleExternalError(context, false, function () {623 return context.tokenMatcher.match_Other(token);624 });625 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1const Parser = require('./lib/parser');2const Compiler = require('./lib/pickles/compiler');3const Watcher = require('./lib/watcher');4const fs = require('fs');5const glob = require('glob');6const parserObj = new Parser();7const watcherObj = new Watcher();8let path = undefined;9let cypressOptions = undefined;10const appRoot = process.cwd();11const dynamicReloading = false;12/**13 * This function loads the cypress config array14 */15const loadCypressOptions = () => {16 if("undefined" === typeof cypressOptions) {17 cypressOptions = JSON.parse(18 fs.readFileSync(`${appRoot}/cypress.json`, "utf-8")19 );20 if("undefined" !== typeof cypressOptions.dill){21 cypressOptions = cypressOptions.dill;22 }23 }24};25/**26 * Returns the path of the of the stepDefinitons file27 *28 * @returns {string|number}29 */30const getStepsPath = () => {31 loadCypressOptions();32 const path = cypressOptions.stepDefinitions;33 if(typeof path === "undefined"){34 console.error("Error: Property 'stepsDefinitions' not set in cypress.json");35 return -1;36 }37 return path;38};39/**40 * Reads a steps file and loads the parses the data41 *42 * @param file43 * @throws {CompositeParserException} Will throw an error if the file can't be parsed44 * @returns {GherkinDocument}45 */46const loadSteps = (path) => {47 const data = fs.readFileSync(path, 'utf-8');48 const ast = parserObj.parse(data);49 return ast;50};51/**52 * All the steps get printed to a temporary file, which will be read in the test case execution53 *54 * @param steps55 */56const writeStepsToFile = (steps) => {57 const path = cypressOptions.stepDefinitionTemp;58 fs.writeFile(path, JSON.stringify(steps), (err) => {59 if (err) {60 console.error(`Error: Could not write to file ${path}`);61 return;62 }63 console.log(`Wrote steps file: ${path}`);64 });65};66/**67 * If the contents of the path change, the test will automatically reload68 *69 * @param files array70 * @param steps71 */72const watchForChanges = (files, steps) => {73 watcherObj.watch(files, steps, (file) => {74 steps[file.replace(/\\/g, '/')] = loadSteps(file);75 writeStepsToFile(steps);76 });77};78module.exports = () => {79 let steps = {};80 path = getStepsPath();81 let files = glob.sync(`${path}`);82 let i;83 for(i = 0; i < files.length; i++) {84 let file = files[i];85 console.log(`parsing: ${file}`);86 let result = loadSteps(file);87 steps[file.replace(/\\/g, '/')] = result;88 }89 writeStepsToFile(steps);90 if(dynamicReloading) {91 watchForChanges(files, steps);92 }...

Full Screen

Full Screen

errors.js

Source:errors.js Github

copy

Full Screen

...28 .map(function(e) {29 return e.message30 })31 .join('\n')32 var err = new Errors.CompositeParserException(message)33 err.errors = errors34 return err35}3637Errors.UnexpectedTokenException.create = function(38 token,39 expectedTokenTypes,40 stateComment41) {42 var message =43 'expected: ' +44 expectedTokenTypes.join(', ') +45 ", got '" +46 token.getTokenValue().trim() + ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var Cucumber = require('cucumber');2var fs = require('fs');3var gherkin = require('gherkin');4var parser = new gherkin.Parser();5var lexer = new gherkin.Lexer('en');6var feature = fs.readFileSync('test.feature', 'utf8');7var tokens = lexer.lex(feature);8var parserException = new Cucumber.Gherkin.ParserException();9var compositeParserException = new Cucumber.Gherkin.CompositeParserException(parserException);10var ast = parser.parse(tokens, compositeParserException);11if (compositeParserException.getExceptions().length > 0) {12 console.log(compositeParserException.getExceptions()[0].message);13}14else {15 console.log('no error');16}17var Cucumber = require('cucumber');18var fs = require('fs');19var gherkin = require('gherkin');20var parser = new gherkin.Parser();21var lexer = new gherkin.Lexer('en');22var feature = fs.readFileSync('test.feature', 'utf8');23var tokens = lexer.lex(feature);24var parserException = new Cucumber.Parser.ParserException();25var compositeParserException = new Cucumber.Parser.CompositeParserException(parserException);26var ast = parser.parse(tokens, compositeParserException);27if (compositeParserException.getExceptions().length > 0) {28 console.log(compositeParserException.getExceptions()[0].message);29}30else {31 console.log('no error');32}33var Cucumber = require('cucumber');34var fs = require('fs');35var gherkin = require('gherkin');36var parser = new gherkin.Parser();37var lexer = new gherkin.Lexer('en');38var feature = fs.readFileSync('test.feature', 'utf8');39var tokens = lexer.lex(feature);40var parserException = new Cucumber.Parser.ParserException();41var compositeParserException = new Cucumber.Parser.CompositeParserException(parserException);42var ast = parser.parse(tokens, compositeParserException);43if (compositeParserException.getExceptions().length > 0)

Full Screen

Using AI Code Generation

copy

Full Screen

1var Parser = require('gherkin').Parser;2var CompositeParserException = require('gherkin').CompositeParserException;3var parser = new Parser();4try {5 parser.parse('Feature: test6Given test');7} catch (err) {8 if (err instanceof CompositeParserException) {9 console.log(err.errors[0].message);10 }11}12var Parser = require('gherkin').Parser;13var parser = new Parser();14var feature = parser.parse('Feature: test15Given test');

Full Screen

Using AI Code Generation

copy

Full Screen

1var gherkin = require('gherkin');2var CompositeParserException = gherkin.CompositeParserException;3var Parser = gherkin.Parser;4var TokenMatcher = gherkin.TokenMatcher;5var TokenScanner = gherkin.TokenScanner;6var TokenFormatter = gherkin.TokenFormatter;7var TokenMatcher = gherkin.TokenMatcher;8var TokenScanner = gherkin.TokenScanner;9var TokenFormatter = gherkin.TokenFormatter;10var TokenMatcher = gherkin.TokenMatcher;11var TokenScanner = gherkin.TokenScanner;12var TokenFormatter = gherkin.TokenFormatter;13var TokenMatcher = gherkin.TokenMatcher;14var TokenScanner = gherkin.TokenScanner;15var TokenFormatter = gherkin.TokenFormatter;16var TokenMatcher = gherkin.TokenMatcher;17var TokenScanner = gherkin.TokenScanner;18var TokenFormatter = gherkin.TokenFormatter;19var TokenMatcher = gherkin.TokenMatcher;20var TokenScanner = gherkin.TokenScanner;21var TokenFormatter = gherkin.TokenFormatter;22var TokenMatcher = gherkin.TokenMatcher;23var TokenScanner = gherkin.TokenScanner;

Full Screen

Using AI Code Generation

copy

Full Screen

1')[0]);2')[1]);3')[2]);4')[3]);5')[4]);6')[5]);7')[6]);8')[7]);9')[8]);10')[9]);11')[10]);12')[11]);13')[12]);14')[13]);15')[14]);16')[15]);17')[16]);18')[17]);19')[18]);20')[19]);21')[20]);22')[21]);23')[22]);24')[23]);25')[24]);26')[25]);27')[26]);28')[27]);29')[28]);30')[29]);31')[30]);

Full Screen

Using AI Code Generation

copy

Full Screen

1var CompositeParserException = require('cucumber-gherkin').CompositeParserException;2var fs = require('fs');3var featureFile = fs.readFileSync('features/test.feature', 'utf8');4var parser = new CompositeParserException(featureFile);5console.log(parser.getErrors());6Your name to display (optional):7Your name to display (optional):8const { CompositeParserException } = require('cucumber-gherkin/lib/parser');9Your name to display (optional):

Full Screen

Using AI Code Generation

copy

Full Screen

1var Cucumber = require('cucumber');2var fs = require('fs');3var featureFile = fs.readFileSync('test.feature', 'utf8');4var parser = new Cucumber.Gherkin.Parser();5var compositeException = parser.parse(featureFile);6console.log(compositeException);

Full Screen

Using AI Code Generation

copy

Full Screen

1var CompositeParserException = require('cucumber-gherkin').CompositeParserException;2var parser = new Parser();3try {4 parser.parse('Feature: Test');5} catch (error) {6 console.log(error);7}8var CompositeParserException = require('cucumber-gherkin').CompositeParserException;9var parser = new Parser();10try {11 parser.parse('Feature: Test');12} catch (error) {13 console.log(error);14}15var CompositeParserException = require('cucumber-gherkin').CompositeParserException;16var parser = new Parser();17try {18 parser.parse('Feature: Test');19} catch (error) {20 console.log(error);21}22var CompositeParserException = require('cucumber-gherkin').CompositeParserException;23var parser = new Parser();24try {25 parser.parse('Feature: Test');26} catch (error) {27 console.log(error);28}29var CompositeParserException = require('cucumber-gherkin').CompositeParserException;30var parser = new Parser();31try {32 parser.parse('Feature: Test');33} catch (error) {34 console.log(error);35}36var CompositeParserException = require('cucumber-gherkin').CompositeParserException;37var parser = new Parser();38try {39 parser.parse('Feature: Test');40} catch (error) {41 console.log(error);42}43var CompositeParserException = require('cucumber-gherkin').CompositeParserException;44var parser = new Parser();45try {46 parser.parse('Feature: Test');47} catch (error) {48 console.log(error);49}

Full Screen

Using AI Code Generation

copy

Full Screen

1var CompositeParserException = require('cucumber-gherkin').CompositeParserException;2var errors = new CompositeParserException([]);3 {4 location: {5 }6 }7];8console.log(errors.toString());9return errors.toString();10var Cucumber = require('cucumber');11var errors = new Cucumber.Listener.JsonFormatter();12errors.log = function (string) {13 console.log(string);14};15return errors.log();16var Cucumber = require('cucumber');17var errors = new Cucumber.Listener.JsonFormatter();18errors.log = function (string) {19 console.log(string);20};21return errors.log();22var Cucumber = require('cucumber');23var errors = new Cucumber.Listener.JsonFormatter();24errors.log = function (string) {25 console.log(string);26};27return errors.log();28var Cucumber = require('cucumber');29var errors = new Cucumber.Listener.JsonFormatter();30errors.log = function (string) {31 console.log(string);32};33return errors.log();

Full Screen

Using AI Code Generation

copy

Full Screen

1var myParser = require('./myParser');2var myParser = new MyParser();3myParser.parse('my.feature');4var gherkin = require('gherkin');5var Parser = gherkin.Parser;6var CompositeParserException = gherkin.CompositeParserException;7function MyParser() {8 this.parser = new Parser();9}10MyParser.prototype.parse = function (feature, options) {11 try {12 return this.parser.parse(feature, options);13 } catch (e) {14 if (e instanceof CompositeParserException) {15 console.log(e.errors);16 }17 throw e;18 }19}20module.exports = MyParser;

Full Screen

Cucumber Tutorial:

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.

Cucumber Tutorial Chapters:

Here are the detailed Cucumber testing chapters to help you get started:

  • Importance of Cucumber - Learn why Cucumber is important in Selenium automation testing during the development phase to identify bugs and errors.
  • Setting Up Cucumber in Eclipse and IntelliJ - Learn how to set up Cucumber in Eclipse and IntelliJ.
  • Running First Cucumber.js Test Script - After successfully setting up your Cucumber in Eclipse or IntelliJ, this chapter will help you get started with Selenium Cucumber testing in no time.
  • Annotations in Cucumber - To handle multiple feature files and the multiple scenarios in each file, you need to use functionality to execute these scenarios. This chapter will help you learn about a handful of Cucumber annotations ranging from tags, Cucumber hooks, and more to ease the maintenance of the framework.
  • Automation Testing With Cucumber And Nightwatch JS - Learn how to build a robust BDD framework setup for performing Selenium automation testing by integrating Cucumber into the Nightwatch.js framework.
  • Automation Testing With Selenium, Cucumber & TestNG - Learn how to perform Selenium automation testing by integrating Cucumber with the TestNG framework.
  • Integrate Cucumber With Jenkins - By using Cucumber with Jenkins integration, you can schedule test case executions remotely and take advantage of the benefits of Jenkins. Learn how to integrate Cucumber with Jenkins with this detailed chapter.
  • Cucumber Best Practices For Selenium Automation - Take a deep dive into the advanced use cases, such as creating a feature file, separating feature files, and more for Cucumber testing.

Run Cucumber-gherkin automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful