Narcissistic Passion Minified

    gherk
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.1 • Public • Published

    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"
            ]
          }
        ]
      }
    ]

    Install

    npm i gherk

    DownloadsWeekly Downloads

    313

    Version

    2.1.1

    License

    MIT

    Unpacked Size

    30 kB

    Total Files

    11

    Last publish

    Collaborators

    • bakerface