Skip to content

Commit

Permalink
barely working demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyaleksey committed Apr 7, 2016
1 parent ad209b1 commit 686e46d
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
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
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.editorconfig
.gitignore
.npmignore
136 changes: 136 additions & 0 deletions index.js
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, "|'");
}
25 changes: 25 additions & 0 deletions package.json
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"
}
27 changes: 27 additions & 0 deletions readme.md
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

0 comments on commit 686e46d

Please sign in to comment.