Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Update qunit-extras to respect QUnit.config.hidepassed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Feb 12, 2014
1 parent 20f6737 commit 0d162ad
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 54 deletions.
6 changes: 0 additions & 6 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
QUnit.urlParams.nojava = /[?&]nojava=true(?:&|$)/.test(location.search);
QUnit.urlParams.norequire = /[?&]norequire=true(?:&|$)/.test(location.search);

// assign results to `global_test_results` for Sauce Labs
var global_test_results;
QUnit.done(function(results) {
global_test_results = results;
});

(function() {
if (QUnit.urlParams.nojava) {
return;
Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@
/*--------------------------------------------------------------------------*/

QUnit.config.asyncRetries = 10;
QUnit.config.hidepassed = true;

if (!document) {
QUnit.config.noglobals = true;
Expand Down
83 changes: 35 additions & 48 deletions vendor/qunit-extras/qunit-extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
*
* @oruvate
* @param {Array} array The array to iterate over.
* @param {*} target The value to check for.
* @returns {boolean} Returns `true` if the `target` element is found, else `false`.
* @param {*} value The value to check for.
* @returns {boolean} Returns `true` if the `value` is found, else `false`.
*/
function contains(array, value) {
var index = -1,
Expand Down Expand Up @@ -167,7 +167,7 @@
* @private
* @param {Function|string} fn The function to call.
* @param {number} delay The number of milliseconds to delay the `fn` call.
* @param [arg1, arg2, ...] Arguments to invoke `fn` with.
* @param {Array} args Arguments to invoke `fn` with.
* @param {boolean} repeated A flag to specify whether `fn` is called repeatedly.
* @returns {number} The ID of the timeout.
*/
Expand Down Expand Up @@ -217,7 +217,7 @@
* @memberOf context
* @param {Function|string} fn The function to call or string to evaluate.
* @param {number} delay The number of milliseconds to delay each `fn` call.
* @param [arg1, arg2, ...] Arguments to invoke `fn` with.
* @param {...*} [args] Arguments to invoke `fn` with.
* @returns {number} The ID of the timeout.
*/
function setInterval(fn, delay) {
Expand All @@ -230,7 +230,7 @@
* @memberOf context
* @param {Function|string} fn The function to call or string to evaluate.
* @param {number} delay The number of milliseconds to delay the `fn` call.
* @param [arg1, arg2, ...] Arguments to invoke `fn` with.
* @param {...*} [args] Arguments to invoke `fn` with.
* @returns {number} The ID of the timeout.
*/
function setTimeout(fn, delay) {
Expand Down Expand Up @@ -312,12 +312,13 @@
'logs': []
};

/**
* A callback triggered at the start of every test.
*
* @memberOf QUnit
* @param {Object} details An object with `module` and `name` properties.
*/
// add a callback to be triggered when all testing has completed
QUnit.done(function(details) {
// assign results to `global_test_results` for Sauce Labs
context.global_test_results = details;
});

// add a callback to be triggered at the start of every test
QUnit.testStart(function(details) {
var excused = QUnit.config.excused || {},
excusedTests = excused[details.module],
Expand Down Expand Up @@ -389,20 +390,14 @@
};
});

/*------------------------------------------------------------------------*/

// replace poisoned `raises` method
context.raises = QUnit.raises = QUnit['throws'] || QUnit.raises;

/*------------------------------------------------------------------------*/

// add logging extras
if (isPhantomPage || !document) {

/**
* A logging callback triggered when all testing is completed.
*
* @memberOf QUnit
* @param {Object} details An object with properties `failed`, `passed`, `runtime`, and `total`.
*/
// add a callback to be triggered when all testing has completed
QUnit.done(function() {
var ran;
return function(details) {
Expand All @@ -413,15 +408,17 @@
}
ran = true;

var failures = details.failed;

logInline('');
console.log(hr);
console.log(' PASS: ' + details.passed + ' FAIL: ' + details.failed + ' TOTAL: ' + details.total);
console.log(' PASS: ' + details.passed + ' FAIL: ' + failures + ' TOTAL: ' + details.total);
console.log(' Finished in ' + details.runtime + ' milliseconds.');
console.log(hr);

// exit out of Node.js or PhantomJS
try {
if (details.failed) {
if (failures) {
process.exit(1);
} else {
process.exit(0);
Expand All @@ -430,7 +427,7 @@

// exit out of Narwhal, Rhino, or RingoJS
try {
if (details.failed) {
if (failures) {
java.lang.System.exit(1);
} else {
quit();
Expand All @@ -439,12 +436,7 @@
};
}());

/**
* A logging callback triggered after every assertion.
*
* @memberOf QUnit
* @param {Object} details An object with properties `actual`, `expected`, `message`, and `result`.
*/
// add a callback to be triggered after every assertion
QUnit.log(function(details) {
var expected = details.expected,
result = details.result,
Expand All @@ -462,12 +454,7 @@
QUnit.config.extrasData.logs.push(message.join(' | '));
});

/**
* A logging callback triggered at the start of every test module.
*
* @memberOf QUnit
* @param {Object} details An object with property `name`.
*/
// add a callback to be triggered at the start of every test module
QUnit.moduleStart(function(details) {
// reset the `modulePrinted` flag
var newModuleName = details.name;
Expand All @@ -482,30 +469,30 @@
}
});

/**
* A logging callback triggered after a test is completed.
*
* @memberOf QUnit
* @param {Object} details An object with properties `failed`, `name`, `passed`, and `total`.
*/
// add a callback to be triggered after a test is completed
QUnit.testDone(function(details) {
var logs = QUnit.config.extrasData.logs,
var config = QUnit.config,
failures = details.failed,
logs = config.extrasData.logs,
testName = details.name;

if (details.failed > 0) {
if (!config.hidepassed || failures) {
logInline('');
if (!modulePrinted) {
modulePrinted = true;
console.log(hr);
console.log(moduleName);
console.log(hr);
}
var index = -1,
length = logs.length;
console.log(' ' + (failures ? 'FAIL' : 'PASS') + ' - ' + testName);

if (failures) {
var index = -1,
length = logs.length;

console.log(' FAIL - ' + testName);
while(++index < length) {
console.log(' ' + logs[index]);
while(++index < length) {
console.log(' ' + logs[index]);
}
}
}
logs.length = 0;
Expand Down

0 comments on commit 0d162ad

Please sign in to comment.