forked from webdriverio-community/wdio-teamcity-reporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
52 lines (44 loc) · 1.38 KB
/
index.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
'use strict';
const { EventEmitter } = require('events');
const { buildFormatter, events } = require('./lib/message');
const { flow } = require('lodash');
const { inherits } = require('util');
module.exports = WdioTeamcityReporter;
module.exports.reporterName = 'teamcity';
/**
* @param {object} baseReporter
* @param {object} wdioConf
* @param {object} reporterOptions
* @param {boolean} reporterOptions.captureStandardOutput
* @param {boolean} reporterOptions.flowId
* @param {string} reporterOptions.message
* @return {wdioTeamcityReporter}
*/
function WdioTeamcityReporter(baseReporter, wdioConf, reporterOptions = {}) {
this.baseReporter = baseReporter;
const opts = {
captureStandardOutput: typeof reporterOptions.captureStandardOutput === 'boolean'
? reporterOptions.captureStandardOutput
: false,
flowId: typeof reporterOptions.flowId === 'boolean'
? reporterOptions.flowId
: true,
name: typeof reporterOptions.message === 'string'
? reporterOptions.message
: '[title]',
};
this.enableRealTimeOutput(opts);
}
inherits(WdioTeamcityReporter, EventEmitter);
WdioTeamcityReporter.prototype.enableRealTimeOutput = function (opts) {
events.forEach(event => this.on(event, flow(buildFormatter(event, opts), output)));
};
/**
* @param {string} msg
* @return {string}
*/
function output(msg) {
if (msg) {
console.log(msg);
}
}