I'd like to hide the disabled jasmine specs when I run chosen tests. I'll have lot's of tests, so I wouldn't like to scroll down after each refresh to reach the tests which are at the bottom.
Is there any option in jasmine that allows it? I've went through the docs but didn't find anything.
This was a design decision by pivotal as documented by this issue.
https://github.com/pivotal/jasmine/issues/510
Here is the fix from a comment in the issue.
In jasmine-html.js, add a function to recursively determine if a result node has any active specs:
function hasActiveSpec(resultNode) {
if (resultNode.type == "spec" && resultNode.result.status != "disabled") {
return true;
}
if (resultNode.type == 'suite') {
for (var i = 0, j = resultNode.children.length; i < j; i++) {
if (hasActiveSpec(resultNode.children[i])) {
return true;
}
}
}
}
Then, in the summaryList function, just run that filter for suites:
// ...
var resultNode = resultsTree.children[i];
if (resultNode.type == "suite") {
// Don't display inactive suites
if (!hasActiveSpec(resultNode)) {
continue;
}
// var suiteListNode = ...
// ...
}
If you don't want to modify the Jasmine source, you can also add a hook like this (my example assumes jQuery is present):
jasmine.getEnv().addReporter({
jasmineDone: function () {
$(".disabled").parents(".suite").hide();
}
});
See http://jasmine.github.io/2.1/custom_reporter.html for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With