Skip to content

Commit

Permalink
First version. Copied from karma-growl-reporter, growly replaced with…
Browse files Browse the repository at this point in the history
… growl
  • Loading branch information
gm0t committed Sep 23, 2013
1 parent e8aa82f commit cb4e35a
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -6,7 +6,7 @@ lib-cov
*.out
*.pid
*.gz

node_modules
pids
logs
results
Expand Down
44 changes: 44 additions & 0 deletions README.md
@@ -1,2 +1,46 @@
karma-growler-reporter
======================

> Report test results using [growl](https://github.com/visionmedia/node-growl) (copied from [karma-growl-reporter](https://github.com/karma-runner/karma-growl-reporter), growly replaced with growl).
## Installation
This plugin uses [growl](https://github.com/visionmedia/node-growl), which uses [terminal-notifier](https://github.com/alloy/terminal-notifier) for Mac OS X, [libnotify-bin](http://packages.ubuntu.com/search?keywords=libnotify-bin) for Linux and [growlnotify](http://www.growlforwindows.com/gfw/help/growlnotify.aspx) for Windows.

The easiest way is to keep `karma-growler-reporter` as a devDependency in your `package.json`.

```json
{
"devDependencies": {
"karma": "~0.10",
"karma-growl-reporter": "~0.1"
}
}
```

You can simple do it by:
```bash
npm install karma-growler-reporter --save-dev
```


###

## Configuration
```js
// karma.conf.js
module.exports = function(config) {
config.set({
reporters: ['progress', 'growler'],
});
};
```

You can pass list of reporters as a CLI argument too:
```bash
karma start --reporters growler ,dots
```

For more information on Karma see the [homepage].

[homepage]: http://karma-runner.github.com

Binary file added images/error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/failed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/success.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions index.js
@@ -0,0 +1,66 @@
var util = require('util');
var growl = require('growl');
var path = require('path');

var MSG_SUCCESS = '%d tests passed in %s.';
var MSG_FAILURE = '%d/%d tests failed in %s.';
var MSG_ERROR = '';

var OPTIONS = {
success: {
name: 'Success',
title: 'PASSED - %s',
icon: path.join(__dirname, 'images/success.png')
},
failed: {
name: 'Failure',
title: 'FAILED - %s',
icon: path.join(__dirname, 'images/failed.png')
},
error: {
name: 'Aborted',
title: 'ERROR - %s',
icon: path.join(__dirname, 'images/error.png')
}
};

var GrowlReporter = function(helper, logger, config) {
var log = logger.create('reporter.growler');

var optionsFor = function(type, browser) {
var prefix = config && config.prefix ? config.prefix : '';
return helper.merge(
OPTIONS[type],
{title: prefix + util.format(OPTIONS[type].title, browser)}
);
};

this.adapters = [];
this.onBrowserComplete = function(browser) {
var results = browser.lastResult;
var time = helper.formatTimeInterval(results.totalTime);

if (results.disconnected || results.error) {
return growl(MSG_ERROR, optionsFor('error', browser.name));
}

if (results.failed) {
return growl(
util.format(MSG_FAILURE, results.failed, results.total, time),
optionsFor('failed', browser.name)
);
}

growl(
util.format(MSG_SUCCESS, results.success, time),
optionsFor('success', browser.name)
);
};
};

GrowlReporter.$inject = ['helper', 'logger','config.growlerReporter'];

// PUBLISH DI MODULE
module.exports = {
'reporter:growler': ['type', GrowlReporter]
};
Binary file added karma-growler-reporter-0.0.1.tgz
Binary file not shown.
25 changes: 25 additions & 0 deletions package.json
@@ -0,0 +1,25 @@
{
"name": "karma-growler-reporter",
"version": "0.0.1",
"description": "A Karma plugin. Report results with growl (https://npmjs.org/package/growl).",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git://github.com/gm0t/karma-growler-reporter.git"
},
"keywords": [
"growl",
"karma"
],
"author": "Bogdanov Mikhail <admin@gm0t.ru>",
"license": "MIT",
"bugs": {
"url": "https://github.com/gm0t/karma-growler-reporter/issues"
},
"dependencies": {
"growl": "~1.7.0"
}
}

0 comments on commit cb4e35a

Please sign in to comment.