mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Fix qunit-extras sauce reporter.
This commit is contained in:
235
vendor/qunit-extras/qunit-extras.js
vendored
235
vendor/qunit-extras/qunit-extras.js
vendored
@@ -399,29 +399,61 @@
|
||||
*/
|
||||
QUnit.config.extrasData = {
|
||||
|
||||
'logs': [],
|
||||
|
||||
/**
|
||||
* An array of details for each log entry.
|
||||
* The data object for the active test module.
|
||||
*
|
||||
* @memberOf QUnit.config.extrasData
|
||||
* @type Array
|
||||
* @type Object
|
||||
*/
|
||||
'module': {}
|
||||
'module': {},
|
||||
|
||||
/**
|
||||
* The data object for Sauce Labs.
|
||||
*
|
||||
* @memberOf QUnit.config.extrasData
|
||||
* @type Object
|
||||
*/
|
||||
'sauce': {
|
||||
|
||||
/**
|
||||
* An array of failed test details.
|
||||
*
|
||||
* @memberOf QUnit.config.extrasData.sauce
|
||||
* @type Array
|
||||
*/
|
||||
'tests': []
|
||||
}
|
||||
};
|
||||
|
||||
// add a callback to be triggered when all testing has completed
|
||||
QUnit.done(function(details) {
|
||||
// assign results to `global_test_results` for Sauce Labs
|
||||
details.tests = QUnit.config.extrasData.logs;
|
||||
context.global_test_results = details;
|
||||
});
|
||||
/**
|
||||
* Converts an object into a string representation.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @type Function
|
||||
* @param {Object} object The object to stringify.
|
||||
* @returns {string} The result string.
|
||||
*/
|
||||
QUnit.jsDump.parsers.object = (function() {
|
||||
var func = QUnit.jsDump.parsers.object;
|
||||
if (isSilent) {
|
||||
return func;
|
||||
}
|
||||
return function(object) {
|
||||
if (typeof object.rhinoException != 'object') {
|
||||
return func(object);
|
||||
}
|
||||
return object.name +
|
||||
' { message: "' + object.message +
|
||||
'", fileName: "' + object.fileName +
|
||||
'", lineNumber: ' + object.lineNumber + ' }';
|
||||
};
|
||||
}());
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// add a callback to be triggered after every assertion
|
||||
QUnit.log(function(details) {
|
||||
var data = QUnit.config.extrasData;
|
||||
data.logs.push(details);
|
||||
data.module.logs.push(details);
|
||||
QUnit.config.extrasData.module.logs.push(details);
|
||||
});
|
||||
|
||||
// add a callback to be triggered at the start of every test module
|
||||
@@ -455,13 +487,11 @@
|
||||
while (++index < length) {
|
||||
var assert = asserts[index];
|
||||
if (!assert.result && this.retries < config.asyncRetries) {
|
||||
if (!isSilent) {
|
||||
logs.length -= asserts.length;
|
||||
}
|
||||
this.retries++;
|
||||
var oldLength = queue.length;
|
||||
logs.length -= asserts.length;
|
||||
asserts.length = 0;
|
||||
|
||||
var oldLength = queue.length;
|
||||
this.retries++;
|
||||
this.queue();
|
||||
|
||||
unshift.apply(queue, queue.splice(oldLength, queue.length - oldLength));
|
||||
@@ -534,54 +564,20 @@
|
||||
});
|
||||
});
|
||||
|
||||
// replace poisoned `raises` method
|
||||
context.raises = QUnit.raises = QUnit['throws'] || QUnit.raises;
|
||||
// add a callback to be triggered after a test is completed
|
||||
QUnit.testDone(function(details) {
|
||||
var config = QUnit.config,
|
||||
data = config.extrasData,
|
||||
failures = details.failed,
|
||||
hidepassed = config.hidepassed,
|
||||
module = data.module,
|
||||
moduleLogs = module.logs,
|
||||
sauceTests = data.sauce.tests;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// add logging extras
|
||||
if (!isSilent) {
|
||||
// add a callback to be triggered when all testing has completed
|
||||
QUnit.done(function(details) {
|
||||
var failures = details.failed,
|
||||
statusColor = failures ? 'magenta' : 'green';
|
||||
|
||||
logInline();
|
||||
console.log(hr);
|
||||
console.log(color(statusColor, ' PASS: ' + details.passed + ' FAIL: ' + failures + ' TOTAL: ' + details.total));
|
||||
console.log(color(statusColor, ' Finished in ' + details.runtime + ' milliseconds.'));
|
||||
console.log(hr);
|
||||
|
||||
// exit out of Node.js or PhantomJS
|
||||
try {
|
||||
if (failures) {
|
||||
process.exit(1);
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// exit out of Narwhal, Rhino, or RingoJS
|
||||
try {
|
||||
if (failures) {
|
||||
java.lang.System.exit(1);
|
||||
} else {
|
||||
quit();
|
||||
}
|
||||
} catch(e) {}
|
||||
});
|
||||
|
||||
// add a callback to be triggered after a test is completed
|
||||
QUnit.testDone(function(details) {
|
||||
var config = QUnit.config,
|
||||
module = config.extrasData.module,
|
||||
logs = module.logs,
|
||||
failures = details.failed,
|
||||
hidepassed = config.hidepassed;
|
||||
|
||||
if (hidepassed && !failures) {
|
||||
return;
|
||||
}
|
||||
if (hidepassed && !failures) {
|
||||
return;
|
||||
}
|
||||
if (!isSilent) {
|
||||
logInline();
|
||||
if (!module.printed) {
|
||||
module.printed = true;
|
||||
@@ -590,59 +586,80 @@
|
||||
console.log(hr);
|
||||
}
|
||||
console.log(' ' + (failures ? color('red', 'FAIL') : color('green', 'PASS')) + ' - ' + details.name);
|
||||
}
|
||||
if (!failures) {
|
||||
return;
|
||||
}
|
||||
var index = -1,
|
||||
length = moduleLogs.length;
|
||||
|
||||
if (!failures) {
|
||||
return;
|
||||
while(++index < length) {
|
||||
var entry = moduleLogs[index];
|
||||
if (hidepassed && entry.result) {
|
||||
continue;
|
||||
}
|
||||
var index = -1,
|
||||
length = logs.length;
|
||||
var expected = entry.expected,
|
||||
result = entry.result,
|
||||
type = typeof expected != 'undefined' ? 'EQ' : 'OK';
|
||||
|
||||
while(++index < length) {
|
||||
var log = logs[index];
|
||||
if (hidepassed && log.result) {
|
||||
continue;
|
||||
}
|
||||
var expected = log.expected,
|
||||
result = log.result,
|
||||
type = typeof expected != 'undefined' ? 'EQ' : 'OK';
|
||||
var message = [
|
||||
result ? color('green', 'PASS') : color('red', 'FAIL'),
|
||||
type,
|
||||
entry.message || 'ok'
|
||||
];
|
||||
|
||||
var message = [
|
||||
result ? color('green', 'PASS') : color('red', 'FAIL'),
|
||||
type,
|
||||
log.message || 'ok'
|
||||
];
|
||||
|
||||
if (!result && type == 'EQ') {
|
||||
message.push(color('magenta', 'Expected: ' + expected + ', Actual: ' + log.actual));
|
||||
}
|
||||
if (!result && type == 'EQ') {
|
||||
message.push(color('magenta', 'Expected: ' + expected + ', Actual: ' + entry.actual));
|
||||
}
|
||||
if (!isSilent) {
|
||||
console.log(' ' + message.join(' | '));
|
||||
}
|
||||
});
|
||||
if (!entry.result) {
|
||||
sauceTests.push(entry);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Converts an object into a string representation.
|
||||
*
|
||||
* @memberOf QUnit
|
||||
* @type Function
|
||||
* @param {Object} object The object to stringify.
|
||||
* @returns {string} The result string.
|
||||
*/
|
||||
QUnit.jsDump.parsers.object = (function() {
|
||||
var func = QUnit.jsDump.parsers.object;
|
||||
return function(object) {
|
||||
if (typeof object.rhinoException != 'object') {
|
||||
return func(object);
|
||||
}
|
||||
return object.name +
|
||||
' { message: "' + object.message +
|
||||
'", fileName: "' + object.fileName +
|
||||
'", lineNumber: ' + object.lineNumber + ' }';
|
||||
};
|
||||
}());
|
||||
}
|
||||
// add a callback to be triggered when all testing has completed
|
||||
QUnit.done(function(details) {
|
||||
var failures = details.failed,
|
||||
statusColor = failures ? 'magenta' : 'green';
|
||||
|
||||
if (!isSilent) {
|
||||
logInline();
|
||||
console.log(hr);
|
||||
console.log(color(statusColor, ' PASS: ' + details.passed + ' FAIL: ' + failures + ' TOTAL: ' + details.total));
|
||||
console.log(color(statusColor, ' Finished in ' + details.runtime + ' milliseconds.'));
|
||||
console.log(hr);
|
||||
}
|
||||
// exit out of Node.js or PhantomJS
|
||||
try {
|
||||
if (failures) {
|
||||
process.exit(1);
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// exit out of Narwhal, Rhino, or RingoJS
|
||||
try {
|
||||
if (failures) {
|
||||
java.lang.System.exit(1);
|
||||
} else {
|
||||
quit();
|
||||
}
|
||||
} catch(e) {}
|
||||
|
||||
// assign results to `global_test_results` for Sauce Labs
|
||||
details.tests = QUnit.config.extrasData.sauce.tests;
|
||||
context.global_test_results = details;
|
||||
});
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
// replace poisoned `raises` method
|
||||
context.raises = QUnit.raises = QUnit['throws'] || QUnit.raises;
|
||||
|
||||
// add CLI extras
|
||||
if (!document) {
|
||||
// Timeout fallbacks based on the work of Andrea Giammarchi and Weston C.
|
||||
|
||||
Reference in New Issue
Block a user