Skip to content

Commit

Permalink
Docs: Add section about customizing RuleTester (fixes #6227) (#6331)
Browse files Browse the repository at this point in the history
* Docs: Add section about customizing RuleTester (fixes #6227)

* Rewording after feedback

* Added example
  • Loading branch information
jfmengels authored and nzakas committed Jun 9, 2016
1 parent 0e14016 commit 477fbc1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/developer-guide/working-with-plugins.md
Expand Up @@ -140,6 +140,31 @@ ruleTester.run("custom-plugin-rule", rule, {
});
```

#### Customizing RuleTester

To create tests for each valid and invalid case, `RuleTester` internally uses `describe` and `it` methods from the Mocha test framework when it is available. If you use another test framework, you can override `RuleTester.describe` and `RuleTester.it` to make `RuleTester` compatible with it and have proper individual tests and feedback.

Example:

```js
"use strict";

var RuleTester = require("eslint").RuleTester;
var test = require("my-test-runner");

RuleTester.describe = function(text, method) {
RuleTester.it.title = text;
return method.apply(this);
};

RuleTester.it = function(text, method) {
test(RuleTester.it.title + ": " + text, method);
};

// then use RuleTester as documented
```


## Share Plugins

In order to make your plugin available to the community you have to publish it on npm.
Expand Down

0 comments on commit 477fbc1

Please sign in to comment.