Name: js-handler/node_modules/nodeunit/lib/reporters/skip_passed.js
| 1: | /*! |
| 2: | * Nodeunit |
| 3: | * Copyright (c) 2010 Caolan McMahon |
| 4: | * MIT Licensed |
| 5: | */ |
| 6: | |
| 7: | /** |
| 8: | * Module dependencies |
| 9: | */ |
| 10: | |
| 11: | var nodeunit = require('../nodeunit'), |
| 12: | utils = require('../utils'), |
| 13: | fs = require('fs'), |
| 14: | path = require('path'), |
| 15: | AssertionError = require('assert').AssertionError; |
| 16: | |
| 17: | /** |
| 18: | * Reporter info string |
| 19: | */ |
| 20: | |
| 21: | exports.info = "Skip passed tests output"; |
| 22: | |
| 23: | /** |
| 24: | * Run all tests within each module, reporting the results to the command-line. |
| 25: | * |
| 26: | * @param {Array} files |
| 27: | * @api public |
| 28: | */ |
| 29: | |
| 30: | exports.run = function (files, options, callback) { |
| 31: | |
| 32: | if (!options) { |
| 33: | // load default options |
| 34: | var content = fs.readFileSync( |
| 35: | __dirname + '/../../bin/nodeunit.json', 'utf8' |
| 36: | ); |
| 37: | options = JSON.parse(content); |
| 38: | } |
| 39: | |
| 40: | var error = function (str) { |
| 41: | return options.error_prefix + str + options.error_suffix; |
| 42: | }; |
| 43: | var ok = function (str) { |
| 44: | return options.ok_prefix + str + options.ok_suffix; |
| 45: | }; |
| 46: | var bold = function (str) { |
| 47: | return options.bold_prefix + str + options.bold_suffix; |
| 48: | }; |
| 49: | var assertion_message = function (str) { |
| 50: | return options.assertion_prefix + str + options.assertion_suffix; |
| 51: | }; |
| 52: | |
| 53: | var start = new Date().getTime(); |
| 54: | var paths = files.map(function (p) { |
| 55: | return path.join(process.cwd(), p); |
| 56: | }); |
| 57: | |
| 58: | nodeunit.runFiles(paths, { |
| 59: | testspec: options.testspec, |
| 60: | testFullSpec: options.testFullSpec, |
| 61: | moduleStart: function (name) { |
| 62: | console.log('\n' + bold(name)); |
| 63: | }, |
| 64: | testDone: function (name, assertions) { |
| 65: | if (assertions.failures()) { |
| 66: | console.log(error('✖ ' + name) + '\n'); |
| 67: | assertions.forEach(function (a) { |
| 68: | if (a.failed()) { |
| 69: | a = utils.betterErrors(a); |
| 70: | if (a.error instanceof AssertionError && a.message) { |
| 71: | console.log( |
| 72: | 'Assertion Message: ' + assertion_message(a.message) |
| 73: | ); |
| 74: | } |
| 75: | console.log(a.error.stack + '\n'); |
| 76: | } |
| 77: | }); |
| 78: | } |
| 79: | }, |
| 80: | moduleDone: function (name, assertions) { |
| 81: | if (!assertions.failures()) { |
| 82: | console.log('✔ all tests passed'); |
| 83: | } |
| 84: | else { |
| 85: | console.log(error('✖ some tests failed')); |
| 86: | } |
| 87: | }, |
| 88: | done: function (assertions) { |
| 89: | var end = new Date().getTime(); |
| 90: | var duration = end - start; |
| 91: | if (assertions.failures()) { |
| 92: | console.log( |
| 93: | '\n' + bold(error('FAILURES: ')) + assertions.failures() + |
| 94: | '/' + assertions.length + ' assertions failed (' + |
| 95: | assertions.duration + 'ms)' |
| 96: | ); |
| 97: | } |
| 98: | else { |
| 99: | console.log( |
| 100: | '\n' + bold(ok('OK: ')) + assertions.length + |
| 101: | ' assertions (' + assertions.duration + 'ms)' |
| 102: | ); |
| 103: | } |
| 104: | |
| 105: | if (callback) callback(assertions.failures() ? new Error('We have got test failures.') : undefined); |
| 106: | } |
| 107: | }); |
| 108: | }; |
