theintern/intern — pull request #181 by treasonx (2014-04-28 19:39:52+00:00)
Title: Allow configuration of reporters and coverage threshold.

This pull request adds features to address the requirements outlined in https://github.com/theintern/intern/issues/141

## Pass configuration to reporters.

I have added the ability to pass configuration data to the reporters from the intern configuration file. Configuration for the reporters can now have the following structure.

```javascript
{
"reporters": [
"console", {
"id": "lcov",
"config": {
"dir": "./output/"
}
}, {
"id": "lcovhtml",
"config": {
"dir": "./output/"
}
}
]
}
```

The API for authoring a reporter has changed slightly. When defining the `start` function of a reporter you will be passed a configuration object from the intern configuration if provided.

## Configure coverage thresholds

In the intern configuration you can now specify the coverage thresholds which should be met for the runner to exit successfully. The threshold settings can be provided in the intern configuration in two forms.

The coverage threshold settings follow the values allowed by istanbul

### Percentage coverage

The minimum threshold the unit must reach to be considered passing.

```javascript
{
coverageThresholds: {
statements: 74,
branches: 62,
functions: 76,
lines: 74
}
}
```

### Non-percentage coverage

The maximum allowed uncovered entities.

```javascript
{
coverageThresholds: {
statements: -10,
branches: -10,
functions: -10,
lines: -10
}
}
```

When a coverage threshold is configured a new event, `/coverage/error`, is published if the threshold is not met. The subscribers will be passed a text representation of the failures determined by the threshold check. This can be used by reporter authors to report the failure of the coverage threshold check appropriately.

## Wiki updates.

The following wiki articles should be updated when this pull request is merged.

https://github.com/theintern/intern/wiki/Configuring-Intern - update the reporter configuration to explain the reporter configuration option.

https://github.com/theintern/intern/wiki/Using-and-Writing-Reporters - update the reporter API to explain the reporter configuration. Also document the `/coverage/error` even which will be published if coverage threshold checks fail.