-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad209b1
commit 686e46d
Showing
5 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
# cheat sheet: http://EditorConfig.org |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.editorconfig | ||
.gitignore | ||
.npmignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
const inherits = require('util').inherits; | ||
const EventEmitter = require('events').EventEmitter; | ||
|
||
/** | ||
* http://webdriver.io/guide/reporters/customreporter.html | ||
* https://github.com/webdriverio/webdriverio/blob/master/lib/utils/BaseReporter.js | ||
*/ | ||
function WdioTeamcityReporter() { | ||
EventEmitter.call(this); | ||
|
||
/** | ||
* @param {object} suite | ||
* @param {string} suite.type | ||
* @param {string} suite.title | ||
* @param {string} suite.parent | ||
* @param {boolean} suite.pending | ||
* @param {string} suite.file | ||
* @param {string[]} suite.specs | ||
* @param {string} suite.event | ||
* @param {object} suite.runner | ||
*/ | ||
this.on('suite:start', suite => { | ||
console.log(`##teamcity[testSuiteStarted name='${escape(suite.title)}']`); | ||
}); | ||
|
||
/** | ||
* @param {object} suite | ||
* @param {string} suite.type | ||
* @param {string} suite.title | ||
* @param {string} suite.parent | ||
* @param {boolean} suite.pending | ||
* @param {string} suite.file | ||
* @param {string[]} suite.specs | ||
* @param {string} suite.event | ||
* @param {object} suite.runner | ||
* @param {string} suite.specHash | ||
*/ | ||
this.on('test:start', test => { | ||
console.log(`##teamcity[testStarted name='${escape(test.title)}' captureStandardOutput='true']"`); | ||
}); | ||
|
||
/** | ||
* @param {object} suite | ||
* @param {string} suite.type | ||
* @param {string} suite.title | ||
* @param {string} suite.parent | ||
* @param {boolean} suite.pending | ||
* @param {string} suite.file | ||
* @param {string[]} suite.specs | ||
* @param {string} suite.event | ||
* @param {object} suite.runner | ||
* @param {string} suite.specHash | ||
*/ | ||
this.on('test:end', test => { | ||
console.log(`##teamcity[testFinished name='${escape(test.title)}' duration='']`); | ||
}); | ||
|
||
/** | ||
* @param {object} suite | ||
* @param {string} suite.type | ||
* @param {object} suite.err | ||
* @param {string} suite.title | ||
* @param {string} suite.parent | ||
* @param {boolean} suite.pending | ||
* @param {string} suite.file | ||
* @param {string[]} suite.specs | ||
* @param {string} suite.event | ||
* @param {object} suite.runner | ||
* @param {string} suite.specHash | ||
*/ | ||
this.on('test:fail', test => { | ||
console.log(`##teamcity[testFailed name='${escape(test.title)}' message='${escape(suite.err.message)}' captureStandardOutput='true' details='${escape(suite.err.stack)}']`); | ||
}); | ||
|
||
/** | ||
* @param {object} suite | ||
* @param {string} suite.type | ||
* @param {string} suite.title | ||
* @param {string} suite.parent | ||
* @param {boolean} suite.pending | ||
* @param {string} suite.file | ||
* @param {string[]} suite.specs | ||
* @param {string} suite.event | ||
* @param {object} suite.runner | ||
* @param {string} suite.specHash | ||
*/ | ||
this.on('test:pending', test => { | ||
console.log(`##teamcity[testIgnored name='${escape(test.title)}' message='pending']`); | ||
}); | ||
|
||
/** | ||
* @param {object} suite | ||
* @param {string} suite.type | ||
* @param {string} suite.title | ||
* @param {string} suite.parent | ||
* @param {boolean} suite.pending | ||
* @param {string} suite.file | ||
* @param {string[]} suite.specs | ||
* @param {string} suite.event | ||
* @param {object} suite.runner | ||
* @param {string} suite.specHash | ||
*/ | ||
this.on('suite:end', suite => { | ||
console.log(`##teamcity[testSuiteFinished name='${escape(suite.title)}' duration='']`); | ||
}); | ||
} | ||
|
||
inherits(WdioTeamcityReporter, EventEmitter); | ||
|
||
module.exports = WdioTeamcityReporter; | ||
module.exports.reporterName = 'teamcity'; | ||
|
||
/** | ||
* Escape the given `str`. | ||
* | ||
* @param {string} str | ||
* @return {string} | ||
*/ | ||
function escape(str) { | ||
if (!str) { | ||
return ''; | ||
} | ||
|
||
return str | ||
.toString() | ||
.replace(/\x1B.*?m/g, "") | ||
.replace(/\|/g, "||") | ||
.replace(/\n/g, "|n") | ||
.replace(/\r/g, "|r") | ||
.replace(/\[/g, "|[") | ||
.replace(/\]/g, "|]") | ||
.replace(/\u0085/g, "|x") | ||
.replace(/\u2028/g, "|l") | ||
.replace(/\u2029/g, "|p") | ||
.replace(/'/g, "|'"); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "wdio-teamcity-reporter", | ||
"version": "0.0.1", | ||
"description": "Teamcity reporter for WebdriverIO", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sullenor/wdio-teamcity-reporter.git" | ||
}, | ||
"keywords": [ | ||
"teamcity" | ||
], | ||
"author": "Alexey Litvinov", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/sullenor/wdio-teamcity-reporter/issues" | ||
}, | ||
"homepage": "https://github.com/sullenor/wdio-teamcity-reporter#readme" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
wdio-teamcity-reporter | ||
====================== | ||
|
||
Teamcity reporter for WebdriverIO. Under development. | ||
|
||
|
||
## Installation | ||
|
||
```bash | ||
npm install wdio-teamcity-reporter --save-dev | ||
``` | ||
|
||
|
||
## Configuration | ||
|
||
```javascript | ||
exports.config = { | ||
// ... | ||
reporters: ['wdio-teamcity-reporter'], | ||
// ... | ||
} | ||
``` | ||
|
||
|
||
## License | ||
|
||
> The MIT License |