gulp-yadda-steps v0.1.29
gulp-yadda-steps
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
gulp-yadda-steps@0.1.28 - "MIT License (MIT)", documented by npm-licenses.
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago