-
-
Save benthepoet/7402636 to your computer and use it in GitHub Desktop.
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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