Comparing version 0.2.10 to 0.3.0
@@ -83,3 +83,2 @@ var path = require('path'), | ||
data.module = currentModule; | ||
process.send({ | ||
@@ -140,2 +139,2 @@ event: 'assertionDone', | ||
// require tests | ||
options.tests.forEach(load); | ||
options.tests.forEach(load); |
114
lib/log.js
@@ -1,5 +0,5 @@ | ||
var util = require('util'), | ||
Table = require('cli-table'); | ||
var Table = require('cli-table'); | ||
var data; | ||
var data, | ||
log = console.log; | ||
@@ -36,2 +36,38 @@ data = { | ||
/** | ||
* Get global tests stats in unified format | ||
*/ | ||
exports.stats = function() { | ||
var stats = { | ||
files: 0, | ||
assertions: 0, | ||
failed: 0, | ||
passed: 0, | ||
runtime: 0 | ||
}; | ||
data.summaries.forEach(function(file) { | ||
stats.files++; | ||
stats.assertions += file.total; | ||
stats.failed += file.failed; | ||
stats.passed += file.passed; | ||
stats.runtime += file.runtime; | ||
}); | ||
stats.tests = data.tests.length; | ||
return stats; | ||
}; | ||
/** | ||
* Reset global stats data | ||
*/ | ||
exports.reset = function() { | ||
data = { | ||
assertions: [], | ||
tests: [], | ||
summaries: [] | ||
}; | ||
}; | ||
var print = {}; | ||
@@ -67,5 +103,24 @@ | ||
util.print('\nAssertions:\n' + table.toString() + '\n'); | ||
} | ||
log('Assertions:\n' + table.toString()); | ||
}; | ||
print.errors = function() { | ||
var currentModule, module, | ||
currentTest, test; | ||
log('\nErrors:\n'); | ||
data.assertions.forEach(function(data) { | ||
// only log a failed test | ||
if (data.result) { | ||
return; | ||
} | ||
log('Module: ' + data.module + ' Test: ' + data.test); | ||
log('Actual value:'); | ||
log(data.actual); | ||
log('Expected value:'); | ||
log(data.expected); | ||
}); | ||
}; | ||
print.tests = function() { | ||
@@ -91,4 +146,4 @@ var table, | ||
util.print('\Tests:\n' + table.toString() + '\n'); | ||
} | ||
log('\Tests:\n' + table.toString()); | ||
}; | ||
@@ -114,4 +169,4 @@ print.summary = function() { | ||
util.print('\Summary:\n' + table.toString() + '\n'); | ||
} | ||
log('\Summary:\n' + table.toString()); | ||
}; | ||
@@ -130,44 +185,9 @@ print.globalSummary = function() { | ||
util.print('\Global summary:\n' + table.toString() + '\n'); | ||
log('\Global summary:\n' + table.toString()); | ||
}; | ||
/** | ||
* Get global tests stats in unified format | ||
*/ | ||
exports.stats = function() { | ||
var stats = { | ||
files: 0, | ||
assertions: 0, | ||
failed: 0, | ||
passed: 0, | ||
runtime: 0 | ||
}; | ||
data.summaries.forEach(function(file) { | ||
stats.files++; | ||
stats.assertions += file.total; | ||
stats.failed += file.failed; | ||
stats.passed += file.passed; | ||
stats.runtime += file.runtime; | ||
}); | ||
stats.tests = data.tests.length; | ||
return stats; | ||
}; | ||
/** | ||
* Reset global stats data | ||
*/ | ||
exports.reset = function() { | ||
data = { | ||
assertions: [], | ||
tests: [], | ||
summaries: [] | ||
}; | ||
}; | ||
/** | ||
* Print stats table to the stdout | ||
* @param {string} name of the table. | ||
* @param {String} name of the table. | ||
* @api public | ||
*/ | ||
@@ -174,0 +194,0 @@ exports.print = function(name) { |
@@ -6,3 +6,3 @@ var fs = require('fs'), | ||
_ = require('underscore'), | ||
log = require('./log'); | ||
log = exports.log = require('./log'); | ||
@@ -16,2 +16,5 @@ var options; | ||
// log expected and actual values for failed tests | ||
errors: true, | ||
// log all tests messages | ||
@@ -36,2 +39,11 @@ tests: true, | ||
// return error exit status | ||
process.on('exit', function() { | ||
if (log.stats().failed > 0) { | ||
process.exit(1); | ||
} | ||
}); | ||
/** | ||
@@ -126,18 +138,10 @@ * Run one spawned instance with tests | ||
if (filesCount >= files.length) { | ||
if (options.assertions) { | ||
log.print('assertions'); | ||
} | ||
'assertions tests summary globalSummary errors' | ||
.split(' ') | ||
.forEach(function(name) { | ||
if (options[name]) { | ||
log.print(name); | ||
} | ||
}); | ||
if (options.tests) { | ||
log.print('tests'); | ||
} | ||
if (options.summary) { | ||
log.print('summary'); | ||
} | ||
if (options.globalSummary) { | ||
log.print('globalSummary'); | ||
} | ||
if (typeof callback === 'function') { | ||
@@ -156,3 +160,1 @@ callback(log.stats()); | ||
}; | ||
exports.log = log; |
{ | ||
"name": "qunit", | ||
"description": "A port of QUnit unit testing framework to nodejs", | ||
"version": "0.2.10", | ||
"version": "0.3.0", | ||
"author": "Oleg Slobodskoi <oleg008@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -98,6 +98,8 @@ ## This is a port of QUnit unit testing framework to nodejs | ||
{ | ||
// log allassertions messages | ||
assertions: true, | ||
// log expected and actual values for failed tests | ||
errors: true, | ||
// log all tests messages | ||
@@ -122,2 +124,3 @@ tests: true, | ||
// change any option for all tests globally | ||
@@ -124,0 +127,0 @@ testrunner.options.optionName = value; |
var a = require('assert'), | ||
chainer = require('chainer'); | ||
chainer = require('chainer'), | ||
_ = require('underscore'); | ||
@@ -10,6 +11,10 @@ var tr = require('../lib/testrunner'), | ||
tr.options.assertions = false; | ||
tr.options.tests = false; | ||
tr.options.summary = false; | ||
tr.options.globalSummary = false; | ||
_.extend(tr.options, { | ||
assertions: false, | ||
tests: false, | ||
summary: false, | ||
globalSummary: false, | ||
errors: false, | ||
assertions: false | ||
}); | ||
@@ -34,3 +39,3 @@ // reset log stats every time .next is called | ||
}; | ||
delete res.runtime; | ||
a.deepEqual(stat, res, 'base testrunner test'); | ||
@@ -54,2 +59,3 @@ chain.next(); | ||
delete res.runtime; | ||
a.deepEqual(stat, res, 'attaching code to global works'); | ||
@@ -76,2 +82,3 @@ chain.next(); | ||
delete res.runtime; | ||
a.deepEqual(stat, res, 'attaching code to specified namespace works'); | ||
@@ -95,2 +102,3 @@ chain.next(); | ||
delete res.runtime; | ||
a.deepEqual(stat, res, 'async code testing works'); | ||
@@ -97,0 +105,0 @@ chain.next(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193707
4512
267