Last active — forked from kir/qunit.teamcity.js

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

A modified version of the QUnit Team City output. Needed to add a special variable to track the beginning and end of a module because testSuiteFinished were being misplaced or duplicated. Needed to escape the test names in order to use apostrophes. Also added a snippet that sets up window.console.log() as a blank function when it's not present. This is needed otherwise execution will break in Internet Explorer.

View qunit.teamcity.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
(function (QUnit) {
 
if (!window.console) {
window.console = {
log: function () { }
};
}
 
var tcEscape = function (str) {
str = str ? str.toString() : "";
str = str.replace(/\n/g, "|n");
str = str.replace(/\r/g, "|r");
str = str.replace(/(['\[\]])/g, "|$1");
return str;
};
 
var suiteRunning = false;
 
//QUnit.moduleStart({ name })
QUnit.moduleStart = function (settings) {
console.log("##teamcity[testSuiteStarted name='" + settings.name + "']");
suiteRunning = true;
};
 
//QUnit.moduleDone({ name, failed, passed, total })
QUnit.moduleDone = function (settings) {
if (suiteRunning) {
suiteRunning = false;
console.log("##teamcity[testSuiteFinished name='" + settings.name + "']");
}
};
 
//QUnit.testStart({ name })
QUnit.testStart = function (settings) {
console.log("##teamcity[testStarted name='" + tcEscape(settings.name) + "' captureStandardOutput='true']");
};
 
//QUnit.testDone({ name, failed, passed, total })
QUnit.testDone = function (settings) {
console.log("##teamcity[testFinished name='" + tcEscape(settings.name) + "']");
};
 
QUnit.log(function (details) {
if (!details.result) {
var isComparison = details.expected || details.actual;
 
if ((isComparison && ("" + details.actual + details.expected).length > 10)) {
console.log("##teamcity[testFailed type='comparisonFailure' name='" + tcEscape(details.name)
+ "' message='" + tcEscape(details.message)
+ "' details='" + tcEscape(details.source) +
"' expected='" + tcEscape(details.expected) +
"' actual='" + tcEscape(details.actual) + "']");
}
 
var message = "";
if (isComparison) {
message = "Expected: " + details.expected + ", Actual: " + details.actual;
}
if (details.message) {
message = details.message + ": " + message;
}
 
console.log("##teamcity[testFailed name='" + tcEscape(details.name)
+ "' message='" + tcEscape(message) + "' details='" + tcEscape(details.source) + "']");
}
});
 
})(QUnit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.