ext_jasmine.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /**
  2. * Created with JetBrains PhpStorm.
  3. * User: dongyancen
  4. * Date: 13-10-17
  5. * Time: 上午2:24
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. /**
  9. * rewrite jasmine function to support batchrun
  10. */
  11. (function() {
  12. if (!jasmine)
  13. return;
  14. var s = jasmine.Queue.prototype.start
  15. // ,n = jasmine.Queue.prototype.next_
  16. ,f = jasmine.Runner.prototype.finishCallback;
  17. function _f(self,args /* failures, total */) {
  18. //todo 写到调用HtmlReporter后
  19. /*another way to apply:
  20. *
  21. * var reporterView = self.env.reporter.subReporters_[0].getReporterView();
  22. *totalSpecCount,completeSpecCount,failedCount,passedCount
  23. *reporterView.views.specs[0].detail
  24. * */
  25. var totalSpecCount = 0,failedCount = 0,passedCount = 0;
  26. var tmpSpec = null;
  27. for(var i=0;i<self.suites_.length;i++){
  28. for(var j=0;j<self.suites_[i].specs_.length;j++){
  29. totalSpecCount++;
  30. tmpSpec = self.suites_[i].specs_[j].results_.items_;
  31. for(var k=0;k<tmpSpec.length;k++){
  32. if(tmpSpec[k].passed_){
  33. passedCount++;
  34. }else{
  35. failedCount++;
  36. }
  37. }
  38. }
  39. }
  40. //display failed Suite
  41. // $('li.fail ol').toggle();
  42. if (parent && parent.brtest) {
  43. parent.brtest.customTrigger('done', [ new Date().getTime(), {
  44. failed : failedCount,
  45. passed : passedCount,
  46. detail : self.suites_,
  47. total : totalSpecCount
  48. //todo jscoverage
  49. }, window._$jscoverage || null ]);
  50. }
  51. }
  52. jasmine.Runner.prototype.finishCallback = function(){
  53. f.apply(this, arguments);
  54. _f(this,arguments);
  55. };
  56. jasmine.Queue.prototype.start =function(){
  57. //todo
  58. /* wait for import.php return */
  59. // var h = setInterval(function() {
  60. // if (window && window['baidu']) {
  61. // clearInterval(h);
  62. s.apply(this, arguments);
  63. // }
  64. // }, 20);
  65. };
  66. // function _n(self,args /* failures, total */) {
  67. /* // do not delete the following lines:
  68. // the last Queue in the file has done ,there is no more Suite or Queue
  69. if(self.index == self.blocks.length || (this.abort && !this.ensured[self.index])){
  70. }
  71. */
  72. // }
  73. // jasmine.Queue.prototype.next_ = function() {
  74. // _n(this,arguments);
  75. // n.apply(this, arguments);
  76. // };
  77. })();