From 39975e86df35789d4845ba81bdd0a7f6f81085f6 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Mon, 6 Jun 2016 22:54:28 +0200 Subject: [PATCH 1/3] Docs: Add section about customizing RuleTester (fixes #6227) --- docs/developer-guide/working-with-plugins.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/developer-guide/working-with-plugins.md b/docs/developer-guide/working-with-plugins.md index a0d69196b8a..4e2678b7d63 100644 --- a/docs/developer-guide/working-with-plugins.md +++ b/docs/developer-guide/working-with-plugins.md @@ -140,6 +140,11 @@ ruleTester.run("custom-plugin-rule", rule, { }); ``` +#### Customizing RuleTester + +RuleTester internally uses Mocha's `describe` and `it` methods when available to create tests for each valid and invalid case. If you use another test runner, you can override `RuleTester.describe` and `RuleTester.it` to make RuleTester compatible with it and have proper individual tests and feedback. + + ## Share Plugins In order to make your plugin available to the community you have to publish it on npm. From adc62ab7ade48ac8e52509c5c424284b756f676e Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 8 Jun 2016 19:07:10 +0200 Subject: [PATCH 2/3] Rewording after feedback --- docs/developer-guide/working-with-plugins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/developer-guide/working-with-plugins.md b/docs/developer-guide/working-with-plugins.md index 4e2678b7d63..3b4adba2524 100644 --- a/docs/developer-guide/working-with-plugins.md +++ b/docs/developer-guide/working-with-plugins.md @@ -142,7 +142,7 @@ ruleTester.run("custom-plugin-rule", rule, { #### Customizing RuleTester -RuleTester internally uses Mocha's `describe` and `it` methods when available to create tests for each valid and invalid case. If you use another test runner, you can override `RuleTester.describe` and `RuleTester.it` to make RuleTester compatible with it and have proper individual tests and feedback. +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. ## Share Plugins From ac2c2ec84e2c4d6b61fd0dbc783959fab15fd872 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Wed, 8 Jun 2016 23:04:01 +0200 Subject: [PATCH 3/3] Added example --- docs/developer-guide/working-with-plugins.md | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/developer-guide/working-with-plugins.md b/docs/developer-guide/working-with-plugins.md index 3b4adba2524..5e8a7ff6fd5 100644 --- a/docs/developer-guide/working-with-plugins.md +++ b/docs/developer-guide/working-with-plugins.md @@ -142,7 +142,27 @@ 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. +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