/*! * Nodeunit * Copyright (c) 2010 Caolan McMahon * MIT Licensed */ /** * Module dependencies */ var nodeunit = require('../nodeunit'), utils = require('../utils'), fs = require('fs'), path = require('path'), AssertionError = require('assert').AssertionError; /** * Reporter info string */ exports.info = "Report tests result as HTML"; /** * Run all tests within each module, reporting the results to the command-line. * * @param {Array} files * @api public */ exports.run = function (files, options, callback) { var start = new Date().getTime(); var paths = files.map(function (p) { return path.resolve(p); }); console.log(''); console.log(''); console.log(''); console.log(''); console.log(''); console.log(''); nodeunit.runFiles(paths, { testspec: options.testspec, testFullSpec: options.testFullSpec, moduleStart: function (name) { console.log('

' + name + '

'); console.log('
    '); }, testDone: function (name, assertions) { if (!assertions.failures()) { console.log('
  1. ' + name + '
  2. '); } else { console.log('
  3. ' + name); assertions.forEach(function (a) { if (a.failed()) { a = utils.betterErrors(a); if (a.error instanceof AssertionError && a.message) { console.log('
    ' + 'Assertion Message: ' + a.message + '
    '); } console.log('
    ');
                            console.log(a.error.stack);
                            console.log('
    '); } }); console.log('
  4. '); } }, moduleDone: function () { console.log('
'); }, done: function (assertions) { var end = new Date().getTime(); var duration = end - start; if (assertions.failures()) { console.log( '

FAILURES: ' + assertions.failures() + '/' + assertions.length + ' assertions failed (' + assertions.duration + 'ms)

' ); } else { console.log( '

OK: ' + assertions.length + ' assertions (' + assertions.duration + 'ms)

' ); } console.log(''); console.log(''); if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); } }); };