bdd-tree
v0.2.1
Published
Transforms BDD test source into syntax tree
Downloads
30
Maintainers
Readme
bdd-tree
Transforms BDD source into syntax tree
Given a BDD spec like this
// add-spec.js
describe('add', function () {
it('does something', ...);
it('does something else', ...);
});
describe('sub', function () {
it('minus', ...);
});
you can produce a tree of describe
and it
code blocks
npm install bdd-tree
// index.js
var toTree = require('bdd-tree');
var describes = toTree(require('fs').readFileSync('./add-spec.js', 'utf8'));
[{
name: 'add',
its: [{
name: 'does something',
code: ...
}, {
name: 'does something else',
code: ...
}],
code: // entire code for describe callback
}, {
name: 'sub'
...
}]
Can be used to analyze your specs. I use it to generate Markdown code blocks from unit tests to avoid writing manual examples in jsdoc comments. See xplain and grunt-xplain.
Small print
Author: Gleb Bahmutov © 2014
License: MIT - do anything with the code, but don't blame me if it does not work.
Spread the word: tweet, star on github, etc.
Support: if you find any problems with this module, email / tweet / open issue on Github
MIT License
The MIT License (MIT)
Copyright (c) 2014 Gleb Bahmutov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.