Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #6 from marcinlesek/master
Browse files Browse the repository at this point in the history
Upgrade repoter to 0.1.0 - a lot of changes & modes, with backward compatibility
  • Loading branch information
Shafied authored Jun 24, 2019
2 parents e179fb0 + 36abaec commit d5e9162
Show file tree
Hide file tree
Showing 26 changed files with 927 additions and 4,947 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.idea
node_modules
media
media


yarn.lock
package-lock.json
16 changes: 12 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
language: node_js
node_js:
- stable
- v4
- '0.12'
- '0.10'
- 10

cache:
yarn: true
directories:
- node_modules

install:
- yarn

script:
- yarn build
50 changes: 25 additions & 25 deletions Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
var gulp = require('gulp');
var babel = require('gulp-babel');
var mocha = require('gulp-mocha');
var del = require('del');
const gulp = require('gulp');
const babel = require('gulp-babel');
const mocha = require('gulp-mocha');
const del = require('del');

gulp.task('clean', function (cb) {
del('lib', cb);
del('lib', cb);
});

gulp.task('build', ['clean'], function () {
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
return gulp
.src('src/**/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
});

gulp.task('watch', ['build'], function () {
gulp.watch('src/*.js', ['build']);
gulp.watch('src/*.js', ['build']);
});

gulp.task('test', ['build'], function () {
return gulp
.src('test/**.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug
}));
return gulp
.src('test/**.js')
.pipe(mocha({
ui: 'bdd',
reporter: 'spec',
timeout: typeof v8debug === 'undefined' ? 2000 : Infinity // NOTE: disable timeouts in debug
}));
});

gulp.task('preview', ['build'], function () {
var buildReporterPlugin = require('testcafe').embeddingUtils.buildReporterPlugin;
var pluginFactory = require('./lib');
var reporterTestCalls = require('./test/utils/reporter-test-calls');
var plugin = buildReporterPlugin(pluginFactory);
const buildReporterPlugin = require('testcafe').embeddingUtils.buildReporterPlugin;
const pluginFactory = require('./lib');
const reporterTestCalls = require('./test/utils/reporter-test-calls');
const plugin = buildReporterPlugin(pluginFactory);

reporterTestCalls.forEach(function (call) {
plugin[call.method].apply(plugin, call.args);
});
reporterTestCalls.forEach(function (call) {
plugin[call.method].apply(plugin, call.args);
});

process.exit(0);
process.exit(0);
});
180 changes: 159 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
# TestCafe Reporter Slack
### testcafe-reporter-slack

This is a reporter for [TestCafe](http://devexpress.github.io/testcafe). It sends the output of the test to slack.
This is a reporter for [TestCafe](http://devexpress.github.io/testcafe). It sends the output of the test to [Slack](https://slack.com/).

## Purpose
Once configured the repoter sends test results to Slack depending on a .env file from the folder the tests are run from
## Purpose :dart:
Once configured the reporter sends test results to Slack channel, e.g.

## Setup instructions
Follow the instructions bellow to configure this plugin.

First install this package globaly to the machine you would like to run your tests on and then:
![Slack report - success](assets/slack-report-success.png)

## Testing
Running TestCafe with testcafe-reporter-slack.
![Slack report - failed](assets/slack-report-failed.png)

In order to use this TestCafe reporter plugin it is necessary to define .env variables in your test project, hence the folder from where your call TestCafe.
## Installation :construction:

- cd into your test project.
- Edit or create the .env file by adding the following ki-reporter required variables:
Install this reporter as your test project dependency:

```
TESTCAFE_SLACK_WEBHOOK=https://hooks.slack.com/services/*****
TESTCAFE_SLACK_CHANNEL='#testcafe'
TESTCAFE_SLACK_USERNAME=testcafebot
```bash
yarn add testcafe-reporter-slack
```

Now run your tests from the commmand line with the ki-reporter specified, e.g.:
## Setup instructions :wrench:
In order to use this TestCafe reporter plugin, it is necessary to add it as your reporter to your TestCafe.

### Using `.testcaferc.json` config file

Add a reporter name (`slack`) to your `reporter` object:

```json
{
"browsers": [ "chrome" ],
"src": "scenarios",
"reporter": [
{
"name": "slack"
}
]
}
```
$ testcafe chrome 'path/to/test/file.js' --reporter slack
```

When you use TestCafe API, you can pass the reporter name to the `reporter()` method:
### Using TestCafe API

Pass the reporter name (`slack`) to the `reporter()` method:

```js
testCafe
Expand All @@ -42,5 +50,135 @@ testCafe
.run();
```

## Further Documentation
### Necessary configuration

After that, you should define **.env** file with variables in your test project, hence the folder from where your call TestCafe (root directory).

```dotenv
# .env
TESTCAFE_SLACK_WEBHOOK=https://hooks.slack.com/services/*****
```

This is **required minimum to has it working**.

## Options :gear:

Slack reporter have few options which could be configured from both, `.testcaferc.json` or `.env` file as global variables.
**It will first retrieve the values from the TestCafe config file `.testcaferc.json`**, after that from `.env` file.

* :warning: - **required**
* :balloon: - optional
* :link: - deprecated

#### Slack Webhook URL :warning:

**This option is required!** Your Slack channel webhook URL generated from Slack API to allow reporter post there.
It's **not recommended** to pass your `webhookUrl` into the config file, in this case, due to sensitive data, it's **better to pass it via global variable** in `.env` file.
* via `.testcaferc.json`

```json
{
"name": "slack",
"options": {
"webhookUrl": "https://hooks.slack.com/services/*****"
}
}
```

* via `.env` file

```dotenv
# .env
TESTCAFE_SLACK_WEBHOOK=https://hooks.slack.com/services/*****
```

#### Channel :balloon: :link:

Your Slack channel name where you want to post reports.

* via `.testcaferc.json`

```json
{
"name": "slack",
"options": {
"channel": "#testcafe"
}
}
```

* via `.env` file

```dotenv
# .env
TESTCAFE_SLACK_CHANNEL="#testcafe"
```

#### Username :balloon: :link:

Your Slack app username.

* via `.testcaferc.json`

```json
{
"name": "slack",
"options": {
"username": "testcafebot"
}
}
```

* via `.env` file

```dotenv
# .env
TESTCAFE_SLACK_USERNAME=testcafebot
```

#### Logging level

Choose your report logging level, if you want to see each test with error stack trace, choose `TEST` (default). The second one is short & condensed which show the only number of tests which passed, failed and was skipped - `SUMMARY`.

* via `.testcaferc.json`

```json
{
"name": "slack",
"options": {
"loggingLevel": "SUMMARY"
}
}
```

* via `.env` file

```dotenv
# .env
TESTCAFE_SLACK_LOGGING_LEVEL=SUMMARY
```

#### Quiet mode

Choose if you want to have messages in the terminal about sending specific messages to Slack, it's turned off by default.

* via `.testcaferc.json`

```json
{
"name": "slack",
"options": {
"quietMode": true
}
}
```

* via `.env` file

```dotenv
# .env
TESTCAFE_SLACK_QUIET_MODE=true
```

## Further Documentation :books:
[TestCafe Reporter Plugins](https://devexpress.github.io/testcafe/documentation/extending-testcafe/reporter-plugin/)
Binary file added assets/slack-report-failed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/slack-report-success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d5e9162

Please sign in to comment.