0.1.29 • Published 7 years ago

gulp-yadda-steps v0.1.29

Weekly downloads
16
License
MIT License (MIT)
Repository
github
Last release
7 years ago

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

ParamTypeDescription
optsObjectTask 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

ParamTypeDefaultDescription
optsObjectParser configuration options
opts.libraryBasePath=stringSpecifies 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=stringSpecifies a path to the base location for the features. Note: libraryBasePath must also be set for this option to take effect.
opts.librarySuffixstring"-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

ParamTypeDefaultDescription
optsObjectParser configuration options
opts.template_librarystring"../templates/yadda_library.dust"Specifies a path to a template_library dust file. This file controls the layout of new step libraries.
opts.template_insertionstring"../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_stepsstring"../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

gulp-yadda-steps@0.1.28 - "MIT License (MIT)", documented by npm-licenses.

0.1.29

7 years ago

0.1.28

7 years ago

0.1.27

7 years ago

0.1.26

7 years ago

0.1.25

7 years ago

0.1.24

7 years ago

0.1.23

7 years ago

0.1.22

8 years ago

0.1.21

8 years ago

0.1.20

8 years ago

0.1.19

8 years ago

0.1.18

8 years ago

0.1.17

8 years ago

0.1.16

8 years ago

0.1.15

8 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago