-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update reporter to be compatible with wdio v5 #14
Changes from 8 commits
f7a4a31
2298e16
5030557
ded854a
cd4d97f
858fc60
b285f96
1e541b6
4928dc8
3cd81af
aaa5bab
4acffa6
aae35f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
{ | ||
"presets": [ | ||
"es2015" | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"node": "8" | ||
} | ||
} | ||
] | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,4 @@ notifications: | |
|
||
language: node_js | ||
node_js: | ||
- "6" | ||
- "4" | ||
- "0.12" | ||
- "8" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
'use strict'; | ||
|
||
const { EventEmitter } = require('events'); | ||
const WdioReporter = require('@wdio/reporter').default; | ||
const { buildFormatter, events } = require('./lib/message'); | ||
const { flow } = require('lodash'); | ||
const { inherits } = require('util'); | ||
|
||
module.exports = WdioTeamcityReporter; | ||
module.exports.reporterName = 'teamcity'; | ||
|
||
/** | ||
* @param {object} baseReporter | ||
|
@@ -17,36 +13,35 @@ module.exports.reporterName = 'teamcity'; | |
* @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))); | ||
}; | ||
class WdioTeamcityReporter extends WdioReporter { | ||
constructor(reporterOptions) { | ||
Object.assign(reporterOptions, { | ||
captureStandardOutput: typeof reporterOptions.captureStandardOutput === 'boolean' | ||
? reporterOptions.captureStandardOutput | ||
: false, | ||
flowId: typeof reporterOptions.flowId === 'boolean' | ||
? reporterOptions.flowId | ||
: true, | ||
name: typeof reporterOptions.message === 'string' | ||
? reporterOptions.message | ||
: '[title]', | ||
stdout: true, | ||
}); | ||
super(reporterOptions); | ||
this.enableRealTimeOutput(reporterOptions); | ||
} | ||
|
||
/** | ||
* @param {string} msg | ||
* @return {string} | ||
*/ | ||
function output(msg) { | ||
if (msg) { | ||
console.log(msg); | ||
enableRealTimeOutput(opts) { | ||
events.forEach(event => { | ||
this[event] = (...args) => | ||
flow(buildFormatter(event, opts), msg => { | ||
if (msg) { | ||
this.write(msg); | ||
} | ||
})(...args); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = WdioTeamcityReporter; | ||
module.exports.reporterName = 'teamcity'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like wdio tries to use this as a ES6 module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just added that. It should be working now. I was using importing the reporter instead of specifying the name so I didn't catch that. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no new line appended to
this.write
, so everyone gets dumped as a giant blob with no new lines.Can you add one via:
this.write(`${msg}\n`)
See example of usage.