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-js / src / formatter / helpers / keyword_type.js View on Github external
export function getStepKeywordType({ keyword, language, previousKeywordType }) {
  const dialect = Gherkin.dialects()[language]
  const type = _.find(['given', 'when', 'then', 'and', 'but'], key =>
    _.includes(dialect[key], keyword)
  )
  switch (type) {
    case 'when':
      return types.EVENT
    case 'then':
      return types.OUTCOME
    case 'and':
    case 'but':
      if (previousKeywordType) {
        return previousKeywordType
      }
    // fallthrough
    default:
      return types.PRECONDITION
github cucumber / cucumber-js / src / cli / i18n.js View on Github external
export function getLanguages() {
  const rows = _.map(Gherkin.dialects(), (data, isoCode) => [
    isoCode,
    data.name,
    data.native,
  ])
  return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows)
}
github cucumber / cucumber-js / src / cli / i18n.js View on Github external
export function getKeywords(isoCode) {
  const language = Gherkin.dialects()[isoCode]
  const rows = _.map(keywords, keyword => {
    const words = _.map(language[keyword], s => `"${s}"`).join(', ')
    return [titleCase(keyword), words]
  })
  return getAsTable(['ENGLISH KEYWORD', 'NATIVE KEYWORDS'], rows)
}
github cucumber / cucumber-js / src / cli / argv_parser.js View on Github external
static validateLanguage(val) {
    if (!_.includes(_.keys(Gherkin.dialects()), val)) {
      throw new Error(`Unsupported ISO 639-1: ${val}`)
    }
    return val
  }