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.
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.
Share Improve this question asked Jul 22, 2014 at 7:42 Emil A.Emil A. 3,4455 gold badges30 silver badges47 bronze badges 1- 1 I would like to do the same. Version 1.3 would hide the specs that weren't run. – Randall Sutton Commented Aug 12, 2014 at 17:02
5 Answers
Reset to default 3This was a design decision by pivotal as documented by this issue.
https://github./pivotal/jasmine/issues/510
Here is the fix from a ment 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're running tests via Karma, there is a spec reporter plugin that you can configure to ignore various things.
https://www.npmjs./package/karma-spec-reporter
https://www.npmjs./package/karma-spec-reporter-2
I didn't find a way to hide a pending test. But you can add the next style to your test to hide the pending test.
.pending {
display: none;
}
You can see a working example here
Taken from the jasmine intro page...
Suites and specs can be disabled with the xdescribe and xit functions, respectively. These suites and any specs inside them are skipped when run and thus their results will not appear in the results.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744638677a4585302.html
评论列表(0条)