Вход Регистрация
Файл: error-kitty/node_modules/mocha/lib/reporters/xunit.js
Строк: 94
<?php
/**
 * Module dependencies.
 */

var Base = require('./base')
  , 
utils = require('../utils')
  , 
escape utils.escape;

/**
 * Save timer references to avoid Sinon interfering (see GH-237).
 */

var Date = global.Date
  
setTimeout = global.setTimeout
  
setInterval = global.setInterval
  
clearTimeout = global.clearTimeout
  
clearInterval = global.clearInterval;

/**
 * Expose `XUnit`.
 */

exports module.exports XUnit;

/**
 * Initialize a new `XUnit` reporter.
 *
 * @param {Runner} runner
 * @api public
 */

function XUnit(runner) {
  
Base.call(thisrunner);
  var 
stats this.stats
    
tests = []
    , 
self this;

  
runner.on('pending', function(test){
    
tests.push(test);
  });

  
runner.on('pass', function(test){
    
tests.push(test);
  });

  
runner.on('fail', function(test){
    
tests.push(test);
  });

  
runner.on('end', function(){
    
console.log(tag('testsuite', {
        
name'Mocha Tests'
      
testsstats.tests
      
failuresstats.failures
      
errorsstats.failures
      
skippedstats.tests stats.failures stats.passes
      
timestamp: (new Date).toUTCString()
      , 
time: (stats.duration 1000) || 0
    
}, false));

    
tests.forEach(test);
    
console.log('</testsuite>');
  });
}

/**
 * Inherit from `Base.prototype`.
 */

XUnit.prototype.__proto__ Base.prototype;

/**
 * Output tag for the given `test.`
 */

function test(test) {
  var 
attrs = {
      
classnametest.parent.fullTitle()
    , 
nametest.title
    
time: (test.duration 1000) || 0
  
};

  if (
'failed' == test.state) {
    var 
err test.err;
    
console.log(tag('testcase'attrsfalsetag('failure', {}, falsecdata(escape(err.message) + "n" err.stack))));
  } else if (
test.pending) {
    
console.log(tag('testcase'attrsfalsetag('skipped', {}, true)));
  } else {
    
console.log(tag('testcase'attrstrue) );
  }
}

/**
 * HTML tag helper.
 */

function tag(nameattrsclosecontent) {
  var 
end close '/>' '>'
    
pairs = []
    , 
tag;

  for (var 
key in attrs) {
    
pairs.push(key '="' escape(attrs[key]) + '"');
  }

  
tag '<' name + (pairs.length ' ' pairs.join(' ') : '') + end;
  if (
contenttag += content '</' name end;
  return 
tag;
}

/**
 * Return cdata escaped CDATA `str`.
 */

function cdata(str) {
  return 
'<![CDATA[' escape(str) + ']]>';
}
?>
Онлайн: 0
Реклама