-
Notifications
You must be signed in to change notification settings - Fork 11
Public API
Equivalent of featurebook serve
.
var featurebook = require('featurebook').commands;
featurebook.serve(
'path/to/your/specification/directory',
3000
);
Equivalent of featurebook build
.
var featurebook = require('featurebook').commands;
featurebook.build(
'path/to/your/specification/directory',
'pdf',
'path/to/build/output/directory'
);
The API is accessible through the featurebook
module.
var featurebook = require('featurebook');
console.log(featurebook.version); // prints the version of this API
Asynchronously traverses the specification directory and finds the feature files.
Note that the nodes are just references to the *.feature files. We don't want to load
everything into memory. To access the content of a given feature file (i.e. its description, steps, etc)
you call the readFeature()
function. This function is aware of .featurebookignore
file and may skip some files/directories.
featurebook.readFeaturesTree('path/to/a/specs/dir', function (err, featuresTree) {
if (err) throw err;
console.log(featuresTree)
}
Asynchronously reads a given feature and returns its object representation.
featurebook.readFeature('path/to/a/feature/file', function (err, feature) {
}
Asynchronously reads a given spec metadata (featurebook.json):
featurebook.readMetadata('path/to/a/specs/dir', function (err, metadata) {
}
where metadata
is:
{
"title": "Online Banking App",
"version": "v1.0.1",
"authors": [{
"firstName": "CariDee",
"lastName": "English",
"email": "[email protected]"
}],
"contributors": [
]
}
If the title property is not provided it's inferred from the specs dir name, e.g my_spec becomes My spec, or my_specs_goes_here becomes My specs goes here
Asynchronously validates the specs metadata (featurebook.json):
featurebook.validateMetadata('path/to/a/specs/dir', function (err, validationErrors) {
}
Asynchronously reads the specs summary (SUMMARY.md):
featurebook.readSummary('path/to/a/specs/dir', function (err, summary) {
}