Skip to content

@benthepoet /qunit.teamcity.js forked from kir/qunit.teamcity.js
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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. …
(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.