How to use the gherkin.DIALECTS 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 / cucumber-electron / renderer.js View on Github external
const electron = require('electron')
const Convert = require('ansi-to-html')
const convert = new Convert()
const Cucumber = require('cucumber')

// HACK:
// window.Gherkin !== require('gherkin') in browsers, so parsing fails unless:
require('gherkin').Parser = window.Gherkin.Parser
require('gherkin').Compiler = window.Gherkin.Compiler
require('gherkin').DIALECTS = window.Gherkin.DIALECTS


const cli = require('./cli')(electron.remote.process.argv)

function log() {
  const args = [].slice.apply(arguments)
  const htmlSafeOutput = args[0].toString().replace(//g, '>')
  const pre = document.createElement('pre')
  pre.innerHTML = convert.toHtml(htmlSafeOutput, { fg: '#000', bg: '#fff' })
  document.body.appendChild(pre)
}

const PrettyFormatter = Cucumber.Listener.PrettyFormatter
Cucumber.Listener.PrettyFormatter = function(options) {
  options.logToFunction = log
  return PrettyFormatter(options)
github vsiakka / gherkin-lint / src / rules / indentation.js View on Github external
var _ = require('lodash');
var languageMapping = require('gherkin').DIALECTS;
var rule = 'indentation';

var availableConfigs = {
  'Feature': 0,
  'Background': 0,
  'Scenario': 0,
  'Step': 2,
  'given': 2,
  'when': 2,
  'then': 2,
  'and': 2,
  'but': 2
};

var errors = [];
github cucumber / cucumber-js / lib / cucumber / ast / feature.js View on Github external
getScenarioKeyword: function() {
      return Gherkin.DIALECTS[self.getLanguage()].scenario;
    },
github cucumber / cucumber-js / lib / cucumber / ast / step.js View on Github external
hasOutcomeStepKeyword: function hasOutcomeStepKeyword() {
      var language = self.getScenario().getFeature().getLanguage();
      return _.chain(Gherkin.DIALECTS[language].then)
        .includes(self.getKeyword())
        .value();
    },
github cucumber / cucumber-js / src / models / scenario.js View on Github external
constructor(options) {
    const {
      backgroundStepLines,
      feature,
      gherkinData,
      language,
      lineToDescriptionMapping,
      stepLineToKeywordMapping
    } = options

    this.feature = feature
    this.keyword = _.first(Gherkin.DIALECTS[language].scenario)
    this.lines = _.map(gherkinData.locations, 'line')
    this.name = gherkinData.name
    this.tags = _.map(gherkinData.tags, Tag.build)
    this.uri = feature.uri

    this.line = _.first(this.lines)
    this.description = _.chain(this.lines)
      .map(line => lineToDescriptionMapping[line])
      .compact()
      .first()
      .value()

    let previousStep
    this.steps = _.map(gherkinData.steps, gherkinStepData => {
      const step = new Step({
        backgroundLines: backgroundStepLines,
github cucumber / cucumber-js / lib / cucumber / ast / step.js View on Github external
hasRepeatStepKeyword: function hasRepeatStepKeyword() {
      var language = self.getScenario().getFeature().getLanguage();
      return _.chain(Gherkin.DIALECTS[language].and)
        .concat(Gherkin.DIALECTS[language].but)
        .includes(self.getKeyword())
        .value();
    },