How to use the gherkin.AstBuilder 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 SOFTWARE-CLINIC / featurebook / lib / gherkin-model.js View on Github external
'use strict';

var fs = require('fs'),
  Gherkin = require('gherkin'),
  parser = new Gherkin.Parser(new Gherkin.AstBuilder());

module.exports = {
  fromFileSync: fromFileSync
};

function fromFileSync(featurePath) {
  var gherkinDoc = fs.readFileSync(featurePath, 'UTF-8');
  return parser.parse(
    new Gherkin.TokenScanner(gherkinDoc),
    new Gherkin.TokenMatcher()
  );
}
github gregorylimoratto / karma-jasmine-feature / lib / gherkin-preprocessor.js View on Github external
var Gherkin = require('gherkin');
var parser = new Gherkin.Parser(new Gherkin.AstBuilder());
var IGNORE_TAGS = ["@ignore"];
var IGNORE_OTHER_TAGS = ["@ignoreOthers", "@only"];

var createFeaturePreprocessor = function (logger, basePath) {
  var log = logger.create('preprocessor.feature');

  function sanitizeString(str) {
    return str.replace(/'/g, '\\\'').replace(/[\ \t]*[\n\r]+[\ \t]*/g, "\\n\\r' + \n\r\t'");
  }

  function getFeatureTitle(feature) {
    var featureTitle = feature.name;
    if (feature.description) {
      featureTitle += "\r" + feature.description;
    }
    return sanitizeString(featureTitle);
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;
}