JavaScript, Jasmine, hide disabled jasmine specs - Stack Overflow

I'd like to hide the disabled jasmine specs when I run chosen tests. I'll have lot's of

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
Add a ment  | 

5 Answers 5

Reset to default 3

This 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>