npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gherkin-yadda

v0.1.12

Published

Transforms Gherkin-features into yadda library-steps

Downloads

13

Readme

Introduction

This package translates Gherkin-Features to executable yadda-steps and saves them as a .js file. It is an modified extract of the generate function from an great bdd framework called mimik.

Installation

Global:

npm install -g gherkin-yadda

Local:

npm install --save-dev gherkin-yadda

Example

***From: *** Gherkin

Feature: Login
  In order to access the application
  As a registered user
  I need to be able to log in
  Scenario: Successful login

    Given I am a registered user named "Henk"
    When I enter my credentials and submit the login form
    Then I should see a welcome page

***To: *** yadda step library

'use strict';

module.exports = {
	yaddaStepLibrary: yaddaStepLibrary,
	featureBaseName: 'google.feature'
};

var expect = require('chai').expect;
var Yadda = require('yadda'),
	English = Yadda.localisation.English,
	dictionary = new Yadda.Dictionary()
		.define('number', /(d+)/),
	yaddaStepLibrary = English.library(dictionary);

// Given I am a registered user named "Henk"
yaddaStepLibrary.given(/I am a registered user named "$Henk"/, function(input1, done) {

});

// When I enter my credentials and submit the login form
yaddaStepLibrary.when(/I enter my credentials and submit the login form/, function(done) {

});

// Then I should see a welcome page
yaddaStepLibrary.then(/I should see a welcome page/, function(done) {

});

Special Aspects

1. Context Variables

If a word in a feature step is surrounded by double quotes it can be accessed as an parameter of the generated yadda step callback.
Example:

  • Feature Step:
Given I am a registered user named "Henk"
  • Yadda Step:
yaddaStepLibrary.given(/I am a registered user named "$Henk"/, function(input1, done) {
    ...
});

2. Identical Steps

Identical feature steps are going to be generated only one time.

3. Existing Target File

Ýou can choose between the following options if the target file already exists.

3.1 Abort

Gherkin-yadda will be terminated without generating.

3.2 Append

The generated steps will be appended to the existing file. They are not checked for identical steps.

3.3 Merge

Only the yadda step feature descriptions of the existing target file are going to be overwritten. Comments with identical feature descriptions are staying the same.

3.4 Overwrite

The existing target file will be overwritten completely.

How To Use

1. CLI

1.1 Path Specification:

  • Looks recursively for all .feature files in the current cli-path and creates a .js file of them:
gherkin-yadda

  • Does the same as example 1 but with a written folder cli-path:
gherkin-yadda /"yourFolder"

  • Creates a step.js file of the given .feature file:
gherkin-yadda /"yourFolder"/"yourFile.feature"

1.2 Options:

  • Pattern for defining regex variables of the yadda dictionary:
gherkin-yadda -d

  • Use of chai assert library:
gherkin-yadda -c

  • Add the feature basename:
gherkin-yadda -b

  • abort process if target file exists
gherkin-yadda -t

  • append yadda steps if target file exists
gherkin-yadda -a

  • merge yadda steps if target file exists
gherkin-yadda -m

  • overwrite target file completely if it exists
gherkin-yadda -o

2. Node Module

2.1 Include:

The required module will offer you a generate function. It's return value is the output path:

var gherkinYadda = require(gherkin-yadda),
    outputPath = gherkinYadda.generate();

2.2 Params:

All possible params are handed trough an parameter object. Here's an example of all params:

gherkinYadda.generate({
    featureFilePath: "./test",
    displayOutputPath: true,
    useChai : true,
    useDefine: true,
    generateFeatureBaseName: false,
    handleExistingFile: 'merge'
});

The default values are:

  • featureFilePath: current path
  • displayOutputPath: false
  • useChai : false
  • useDefine: false
  • generateFeatureBaseName: false
  • handleExistingFile: 'terminate'

The use of the param "handleExistingFile" prevents an dialog for already existing target files since it decides in advance how to handle existing target files. Possible values are:

  • 'terminate'
  • 'append'
  • 'merge'
  • 'overwrite'

File Location

All generated files are saved into a folder named "step_definitions". It will be created in those directories where the feature files are found.

Todo

  • Recognize language automatically
  • Add cli option for hooks (-h)
  • Include German Gherkin features
  • Offer a template.json for generating yadda steps

Maintainer

kaasbaardje

License

MIT