Extend karma-teamcity-reporter to log browser's output
#KT-32073 fixed #KT-32281 fixed
This commit is contained in:
+43
-28
@@ -103,42 +103,57 @@ class KotlinKarma(override val compilation: KotlinJsCompilation) : KotlinJsTestF
|
|||||||
const LogReporter = function (baseReporterDecorator) {
|
const LogReporter = function (baseReporterDecorator) {
|
||||||
const teamcityReporter = require("karma-teamcity-reporter")["reporter:teamcity"][1];
|
const teamcityReporter = require("karma-teamcity-reporter")["reporter:teamcity"][1];
|
||||||
teamcityReporter.call(this, baseReporterDecorator);
|
teamcityReporter.call(this, baseReporterDecorator);
|
||||||
|
|
||||||
this.logBuffer = [];
|
this.TEST_STD_OUT = "##teamcity[testStdOut name='%s' out='%s' flowId='']";
|
||||||
|
|
||||||
this.TEST_STD_OUT = "##teamcity[testStdOut name='%name%' out='%s' flowId='']";
|
const tcOnBrowserStart = this.onBrowserStart;
|
||||||
|
this.onBrowserStart = function (browser) {
|
||||||
|
tcOnBrowserStart.call(this, browser);
|
||||||
|
this.browserResults[browser.id].consoleCollector = [];
|
||||||
|
};
|
||||||
|
|
||||||
this.onBrowserLog = (browser, log, type) => {
|
this.onBrowserLog = (browser, log, type) => {
|
||||||
this.logBuffer.push(formatMessage(this.TEST_STD_OUT, `[${"$"}{type}] ${"$"}{log}\n`))
|
var browserResult = this.browserResults[browser.id];
|
||||||
|
if (browserResult) {
|
||||||
|
browserResult.consoleCollector.push(`[${"$"}{type}] ${"$"}{log}\n`)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.specSuccess = (browser, result) => {
|
const tcSpecSuccess = this.specSuccess;
|
||||||
const log = this.getLog(browser, result);
|
this.specSuccess = function (browser, result) {
|
||||||
const testName = result.description;
|
tcSpecSuccess.call(this, browser, result);
|
||||||
|
|
||||||
log.push(formatMessage(this.TEST_START, testName));
|
var log = this.getLog(browser, result);
|
||||||
this.logBuffer.forEach(item => {
|
var testName = result.description;
|
||||||
log.push(
|
|
||||||
item.replace('%name%', result.description)
|
const endMessage = log.pop();
|
||||||
)
|
this.browserResults[browser.id].consoleCollector.forEach(item => {
|
||||||
});
|
log.push(
|
||||||
log.push(formatMessage(this.TEST_END, testName, result.time))
|
formatMessage(this.TEST_STD_OUT, testName, item)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
log.push(endMessage);
|
||||||
|
|
||||||
|
this.browserResults[browser.id].consoleCollector = []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tcSpecFailure = this.specFailure;
|
||||||
this.specFailure = function (browser, result) {
|
this.specFailure = function (browser, result) {
|
||||||
const log = this.getLog(browser, result);
|
tcSpecFailure.call(this, browser, result);
|
||||||
const testName = result.description;
|
var log = this.getLog(browser, result);
|
||||||
|
var testName = result.description;
|
||||||
log.push(formatMessage(this.TEST_START, testName));
|
|
||||||
this.logBuffer.forEach(item => {
|
const endMessage = log.pop();
|
||||||
log.push(
|
const failedMessage = log.pop();
|
||||||
item.replace('%name%', result.description)
|
this.browserResults[browser.id].consoleCollector.forEach(item => {
|
||||||
)
|
log.push(
|
||||||
|
formatMessage(this.TEST_STD_OUT, testName, item)
|
||||||
|
)
|
||||||
});
|
});
|
||||||
log.push(formatMessage(this.TEST_FAILED, testName, result.log.join('\n\n')));
|
log.push(failedMessage);
|
||||||
log.push(formatMessage(this.TEST_END, testName, result.time));
|
log.push(endMessage);
|
||||||
|
|
||||||
this.logBuffer = [];
|
this.browserResults[browser.id].consoleCollector = []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user