Skip to content

Instantly share code, notes, and snippets.

@averyvery
Created May 11, 2016 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save averyvery/21cfd2836eed13262d22bc76e8afe4bc to your computer and use it in GitHub Desktop.
Save averyvery/21cfd2836eed13262d22bc76e8afe4bc to your computer and use it in GitHub Desktop.
// better describe() method that nests your describe blocks
// if you pass it a string with slashes
(function() {
var recursiveNestedDescribe = function(title, callback) {
var titleChunk = title.shift();
if (title.length === 0) {
describe(titleChunk, callback);
} else {
describe('/' + titleChunk, function() {
recursiveNestedDescribe(title, callback);
})
}
}
window.nestedDescribe = function(title, callback) {
recursiveNestedDescribe(title.split('/'), callback);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment