How to use the gherkin.Compiler 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 cucumber-attic / microcuke / lib / cucumber / config.js View on Github external
module.exports = function Config() {
  var parser = new Gherkin.Parser();
  var compiler = new Gherkin.Compiler();

  this.buildTestCases = function (glue, gherkinLoader) {
    var pickles = [];

    gherkinLoader.loadGherkinFiles().forEach(function (gherkinFile) {
      var feature = parser.parse(gherkinFile.read());
      pickles = pickles.concat(compiler.compile(feature));
    });
    return pickles.map(function (pickle) {
      return glue.createTestCase(pickle);
    });
  }
};
github cucumber / cucumber-js / lib / cucumber / parser.js View on Github external
function Parser(featureSources, astFilter) {
  var Gherkin      = require('gherkin');
  var Cucumber     = require('../cucumber');

  var parser = new Gherkin.Parser();
  var compiler = new Gherkin.Compiler();

  var self = {
    parse: function parse() {
      var features = [];

      featureSources.forEach(function (featureSource) {
        var uri    = featureSource[Parser.FEATURE_NAME_SOURCE_PAIR_URI_INDEX];
        var source = featureSource[Parser.FEATURE_NAME_SOURCE_PAIR_SOURCE_INDEX];

        var gherkinDocument;
        try {
          gherkinDocument = parser.parse(source);
        } catch(e) {
          e.message += '\npath: ' + uri;
          throw e;
        }
github cucumber / cucumber-js / src / cli / feature_parser.js View on Github external
import Feature from '../models/feature'
import Gherkin from 'gherkin'

const gherkinCompiler = new Gherkin.Compiler()
const gherkinParser = new Gherkin.Parser()

export default class Parser {
  static parse({ scenarioFilter, source, uri }) {
    let gherkinDocument
    try {
      gherkinDocument = gherkinParser.parse(source)
    } catch (error) {
      error.message += '\npath: ' + uri
      throw error
    }

    if (gherkinDocument.feature) {
      return new Feature({
        gherkinData: gherkinDocument.feature,
        gherkinPickles: gherkinCompiler.compile(gherkinDocument, uri),
github cucumber-attic / microcuke / lib / cucumber / pickle_loader.js View on Github external
module.exports = function PickleLoader(otherFilter) {
  var parser = new Gherkin.Parser();
  var compiler = new Gherkin.Compiler();

  this.loadPickles = function (path) {
    var pickles = [];

    var lineFilter, paths;
    if (exists(path) && fs.statSync(path).isDirectory()) {
      paths = glob(path + "/**/*.feature");
      lineFilter = passthrough;
    } else {
      var pathWithLines = new PathWithLines(path);
      paths = pathWithLines.paths;
      lineFilter = pathWithLines.filter;
    }

    paths.forEach(function (featurePath) {
      var gherkin = fs.readFileSync(featurePath, 'utf-8');