2.1.1 • Published 4 years ago

gherk v2.1.1

Weekly downloads
44
License
MIT
Repository
github
Last release
4 years ago

gherk

npm version dependencies dev dependencies downloads

A minimalistic parser for the Gherkin syntax.

import { parse } from "gherk";

const features = parse(`
@beer @example
Feature: Can drink beer when thirsty

  As a drinker
  I want to take beer off the wall
  in order to satisfy my thirst

  Background:
    Given 100 bottles of beer on the wall

  Scenario: Can take a single beer
    When a bottle is taken down
    Then there are 99 bottles of beer on the wall

  Scenario: Can take multiple beers
    When 5 bottles are taken down
    Then there are 95 bottles of beer on the wall

  Scenario: Ghosts can drink
    Given there is nobody in the room
    When 5 bottles are taken down
    And they are floating in the air
    Then there are 95 bottles of beer on the wall
    And there are ghosts in the room
`);

console.log(features);

The code snippet above would output the following JSON object to your console.

[
  {
    "name": "Can drink beer when thirsty",
    "description": "As a drinker I want to take beer off the wall in order to satisfy my thirst",
    "tags": ["beer", "example"],
    "backgrounds": [
      {
        "name": "",
        "description": "",
        "givens": [
          "100 bottles of beer on the wall"
        ]
      }
    ],
    "scenarios": [
      {
        "name": "Can take a single beer",
        "description": "",
        "givens": [],
        "whens": [
          "a bottle is taken down"
        ],
        "thens": [
          "there are 99 bottles of beer on the wall"
        ]
      },
      {
        "name": "Can take multiple beers",
        "description": "",
        "givens": [],
        "whens": [
          "5 bottles are taken down"
        ],
        "thens": [
          "there are 95 bottles of beer on the wall"
        ]
      },
      {
        "name": "Ghosts can drink",
        "description": "",
        "givens": [
          "there is nobody in the room"
        ],
        "whens": [
          "5 bottles are taken down",
          "they are floating in the air"
        ],
        "thens": [
          "there are 95 bottles of beer on the wall",
          "there are ghosts in the room"
        ]
      }
    ]
  }
]
2.1.1

4 years ago

2.0.0

4 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.2

10 years ago

0.0.0

10 years ago