-
Notifications
You must be signed in to change notification settings - Fork 5
/
teamcity.js
64 lines (49 loc) · 1.45 KB
/
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
"use strict";
var tsm = require('teamcity-service-messages');
var REPORTER = 'JSHint';
var groupErrorsByFileName = function (errors) {
return errors.reduce(function (previous, current) {
var error = current.error;
var fileName = current.file;
previous[fileName] || (previous[fileName] = []);
previous[fileName].push({
name: error.reason + " at line " + error.line + ", col " + error.character,
message: error.code + ": " + error.reason,
detailed: error.evidence
});
return previous;
}, {});
};
module.exports = {
toString: function () {
return __filename;
},
reporter: function (errors) {
var errorsByFileName = groupErrorsByFileName(errors);
var fileNames = Object.keys(errorsByFileName);
tsm.testSuiteStarted({ name: REPORTER });
fileNames.forEach(function (fileName) {
var fileErrors = errorsByFileName[fileName];
tsm.testSuiteStarted({ name: fileName });
fileErrors.forEach(function (error) {
var errorName = error.name;
tsm
.testStarted({ name: errorName })
.testFailed({
name: errorName,
message: error.message,
detailed: error.detailed
})
.testFinished({ name: errorName });
});
tsm.testSuiteFinished({ name: fileName });
});
// If there were no errors, tell TeamCity that tests ran successfully
if (errors.length === 0) {
tsm
.testStarted({ name: REPORTER })
.testFinished({ name: REPORTER });
}
tsm.testSuiteFinished({name: REPORTER });
}
};