mirror of
https://github.com/seejohnrun/haste-server
synced 2025-08-19 16:53:12 -07:00
Added node modules
This commit is contained in:
parent
ca9d4c18f7
commit
d1e0644a4e
575 changed files with 77900 additions and 6 deletions
101
node_modules/mocha/lib/reporters/xunit.js
generated
vendored
Normal file
101
node_modules/mocha/lib/reporters/xunit.js
generated
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var Base = require('./base')
|
||||
, utils = require('../utils')
|
||||
, escape = utils.escape;
|
||||
|
||||
/**
|
||||
* Expose `XUnit`.
|
||||
*/
|
||||
|
||||
exports = module.exports = XUnit;
|
||||
|
||||
/**
|
||||
* Initialize a new `XUnit` reporter.
|
||||
*
|
||||
* @param {Runner} runner
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function XUnit(runner) {
|
||||
Base.call(this, runner);
|
||||
var stats = this.stats
|
||||
, tests = []
|
||||
, self = this;
|
||||
|
||||
runner.on('test end', function(test){
|
||||
tests.push(test);
|
||||
});
|
||||
|
||||
runner.on('end', function(){
|
||||
console.log(tag('testsuite', {
|
||||
name: 'Mocha Tests'
|
||||
, tests: stats.tests
|
||||
, failures: stats.failures
|
||||
, errors: stats.failures
|
||||
, skip: stats.tests - stats.failures - stats.passes
|
||||
, timestamp: (new Date).toUTCString()
|
||||
, time: stats.duration / 1000
|
||||
}, 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 = {
|
||||
classname: test.parent.fullTitle()
|
||||
, name: test.title
|
||||
, time: test.duration / 1000
|
||||
};
|
||||
|
||||
if (test.failed) {
|
||||
var err = test.err;
|
||||
attrs.message = escape(err.message);
|
||||
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));
|
||||
} else if (test.pending) {
|
||||
console.log(tag('testcase', attrs, false, tag('skipped', {}, true)));
|
||||
} else {
|
||||
console.log(tag('testcase', attrs, true) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML tag helper.
|
||||
*/
|
||||
|
||||
function tag(name, attrs, close, content) {
|
||||
var end = close ? '/>' : '>'
|
||||
, pairs = []
|
||||
, tag;
|
||||
|
||||
for (var key in attrs) {
|
||||
pairs.push(key + '="' + escape(attrs[key]) + '"');
|
||||
}
|
||||
|
||||
tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
|
||||
if (content) tag += content + '</' + name + end;
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cdata escaped CDATA `str`.
|
||||
*/
|
||||
|
||||
function cdata(str) {
|
||||
return '<![CDATA[' + escape(str) + ']]>';
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue