How to use the gherkin.TokenScanner function in gherkin

To help you get started, we’ve selected a few gherkin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gregorylimoratto / karma-jasmine-feature / lib / gherkin-preprocessor.js View on Github external
return function (content, file, done) {
    log.info('Processing "%s".', file.originalPath);
    var feature;
    try{
       feature = parser.parse(new Gherkin.TokenScanner(content), new Gherkin.TokenMatcher());
    }catch(error){
      log.error('Feature file is incorrect.', file.originalPath);
      log.error(JSON.stringify(error, null, 2));
      done("console.error('error parsing feature file', '" + file.originalPath + "')");
      return;
    }
    
    var featureSpec = "feature('" + getFeatureTitle(feature) + "')";
    if(hasTag(feature.tags, IGNORE_OTHER_TAGS)){
      featureSpec += "\n\t.ignoreOthers()";
    }
    if (hasTag(feature.tags, IGNORE_TAGS)) {
      featureSpec += "\n\t.ignore()";
    }
    
    feature.scenarioDefinitions.forEach(function (scenario) {
github gkushang / cucumber-parallel / lib / tasker / parser.js View on Github external
function parser(feature) {

    var _this = {};
    var parser = new Gherkin.Parser(new Gherkin.AstBuilder());
    parser.stopAtFirstError = false;
    var matcher = new Gherkin.TokenMatcher();
    var scanner = new Gherkin.TokenScanner(fs.readFileSync(feature, 'UTF-8'));

    try {
        _this.feature = parser.parse(scanner, matcher);
        _this.isSucceeded = true;
    } catch (e) {
        log('error in parsing feature ', feature);
        _this.isSucceeded = false;
    }

    return _this;
}
github SOFTWARE-CLINIC / featurebook / lib / gherkin-model.js View on Github external
function fromFileSync(featurePath) {
  var gherkinDoc = fs.readFileSync(featurePath, 'UTF-8');
  return parser.parse(
    new Gherkin.TokenScanner(gherkinDoc),
    new Gherkin.TokenMatcher()
  );
}