admin管理员组文章数量:1429844
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.
本文标签: javascriptJasminehide disabled jasmine specsStack Overflow
版权声明:本文标题:JavaScript, Jasmine, hide disabled jasmine specs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744638676a2616981.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论