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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-yadda-steps

v0.1.29

Published

A gulp task to generate or update Yadda test step libraries from Gherkin features (natural language test scripts).

Downloads

14

Readme

gulp-yadda-steps

view on npm npm module downloads per month Dependency status Build Status Code
Climate Test Coverage

A gulp task to generate or update Yadda test step libraries from Gherkin features (natural language test scripts).

Usage

This gulp task expects a feature file, written in Gherkin syntax, as input, and outputs the matching Yadda test step libraries for this feature file.

As a gulp task

Require this package and use as part of your gulp task.

var GulpYaddaSteps = require('gulp-yadda-steps');
gulp.src('local.feature')
.pipe(new GulpYaddaSteps())
.pipe(fs.createWriteStream('output.js'));

API

Modules

gulp-yadda-steps ⇒ through2

A gulp task to generate or update Yadda test step libraries from Gherkin features (natural language test scripts).

Returns: through2 - readable-stream/transform

| Param | Type | Description | | --- | --- | --- | | opts | Object | Task configuration options (see modules Parser and Render for more information) |

Example
Given the feature file:

Feature: Generate test steps from gherkin features
As a developer
I want to be able to generate test step boilerplate code from gherkin features
So that I can focus effort on building quality test steps

Scenario: Generating test steps

Given I have a simple feature file
When I read the feature file
Then a test steps file is generated

When you pass the feature file to a new gulpYaddaSteps(), and pipe it to a given destination.

var gulpYaddaSteps = require('gulp-yadda-steps');
gulp.src('local.feature')
.pipe(new gulpYaddaSteps())
.pipe(fs.createWriteStream('output.js'));

Then you'll get a Yadda style test step library:

"use strict";
var English = require('yadda').localisation.English;
/* Feature: Generate test steps from gherkin features */
module.exports = (function() {
 return English.library()
   /* Generating test steps */
   .define("Given I have a simple feature file", function(done) {
       this.assert(false);
       done();
   })
   .define("When I read the feature file", function(done) {
       this.assert(false);
       done();
   })
   .define("Then a test steps file is generated", function(done) {
       this.assert(false);
       done();
   });
})();

Note that the output is a vinyl file which will have the filePath overridden if the libraryBasePath and featureBasePath options are set.

/parser ⇒ through2

Parser is a transform stream requiring a valid feature file. Parser will load test step libraries tagged in the feature (using @libraries=) and will attempt to load a file with the feature filename and suffix "-steps.js". If one or more libraries are found they will be used to find step matches in the feature and filter them from the output.

Returns: through2 - readable-stream/transform

| Param | Type | Default | Description | | --- | --- | --- | --- | | opts | Object | | Parser configuration options | | [opts.libraryBasePath=] | string | | Specifies a path to the base location for the test step libraries. E.g. if the base path to the test step library is Test/unit/steps/ use path.join(__dirname, "./steps/") if the script is running from "Test/unit". Note: featureBasePath must also be set for this option to take effect. | | [opts.featureBasePath=] | string | | Specifies a path to the base location for the features. Note: libraryBasePath must also be set for this option to take effect. | | [opts.librarySuffix] | string | "-steps" | Specifies the suffix for step libraries |

Example
Given the feature file:

Feature: Generate test steps from gherkin features
As a developer
I want to be able to generate test step boilerplate code from gherkin features
So that I can focus effort on building quality test steps

Scenario: Generating test steps

Given I have a simple feature file
When I read the feature file
Then a test steps file is generated

When you pass the feature file to a new Parser(), and pipe it to a given destination.

var Parser = require('gulp-yadda-steps').Parser;
gulp.src('local.feature')
.pipe(new Parser())
.pipe(fs.createWriteStream('output.json'));

Then you'll get a Yadda parsed JSON output:

{"feature":{"title":"Generate test steps from gherkin features","annotations":{},
"description":["As a developer","I want to be able to generate test step boilerplate code from gherkin features",
"So that I can focus effort on building quality test steps"],
"scenarios":[{"title":"Generating test steps",
"annotations":{},"description":[],
"steps":["Given I have a simple feature file","When I read the feature file","Then a test steps file is generated"]}]}}

Note that the output is a vinyl file which will have the filePath overridden if the libraryBasePath and featureBasePath options are set.

/render ⇒ through2

Render is a transform stream requiring a yadda parsed JSON file. Render will load test step libraries tagged in the feature (using @libraries=) and will attempt to load a file with the feature filename and suffix "-steps.js". If one or more libraries are found they will be used to find step matches in the feature and filter them from the output.

Returns: through2 - readable-stream/transform

| Param | Type | Default | Description | | --- | --- | --- | --- | | opts | Object | | Parser configuration options | | [opts.template_library] | string | "../templates/yadda_library.dust" | Specifies a path to a template_library dust file. This file controls the layout of new step libraries. | | [opts.template_insertion] | string | "../templates/yadda_insert.dust" | Specifies a path to a template_insertion dust file. This file controls the layout for inserting steps into an existing step library. This template should use dust partial steps to insert generated steps from template_steps. | | [opts.template_steps] | string | "../templates/yadda_steps.dust" | Specifies a path to a template_steps dust file. This file controls the layout and generation of test steps. |

Example
Given a yadda parsed JSON file:

{"feature":{"title":"Generate test steps from gherkin features","annotations":{},
"description":["As a developer","I want to be able to generate test step boilerplate code from gherkin features",
"So that I can focus effort on building quality test steps"],
"scenarios":[{"title":"Generating test steps",
"annotations":{},
"description":[],
"steps":["Given I have a simple feature file","When I read the feature file","Then a test steps file is generated"]}]}}

When you pass the yadda parsed JSON file to a new Render(), and pipe it to a given destination.

var Render = require('gulp-yadda-steps').Render;
gulp.src('output.json')
.pipe(new Render())
.pipe(fs.createWriteStream('output.js'));

Then you'll get a Yadda style test step library:

"use strict";
var English = require('yadda').localisation.English;
var assert = require('assert');
/* Feature: Generate test steps from gherkin features */
module.exports = (function() {
return English.library()
   /* Generating test steps */
   .define("Given I have a simple feature file", function(done) {
       assert(true);
       done();
   })
   .define("When I read the feature file", function(done) {
       assert(true);
       done();
   })
   .define("Then a test steps file is generated", function(done) {
       assert(true);
       done();
   });
})();

Note that the output is a vinyl file which will have the filePath overridden if the libraryBasePath and featureBasePath options are set.

documented by jsdoc-to-markdown.

Changelog

License

MIT License (MIT). All rights not explicitly granted in the license are reserved.

Copyright (c) 2015 John Barry

Dependencies

[email protected] - "MIT License (MIT)", documented by npm-licenses.