diff --git a/docs/rules/valid-test-description.md b/docs/rules/valid-test-description.md index ee39b5b..ecd0124 100644 --- a/docs/rules/valid-test-description.md +++ b/docs/rules/valid-test-description.md @@ -1,17 +1,21 @@ # Match test descriptions against a pre-configured regular expression (valid-test-description) -This rule enforces the test descriptions to follow the desired format. +This rule enforces the test descriptions to follow the desired format. ## Rule Details -By default, the regular expression is configured to be "^should" which requires test descriptions to start with "should". +By default, the regular expression is configured to be "^should" which requires test descriptions to start with "should". By default, the rule supports "it", "specify" and "test" test function names, but it can be configured to look for different test names via rule configuration. Example of a custom rule configuration: ```js rules: { - "mocha/valid-test-description": ["warn", "mypattern$", ["it", "specify", "test", "mytestname"]] + "mocha/valid-test-description": ["warn", "mypattern$", ["it", "specify", "test", "mytestname"], "custom error message"] + }, + // OR + rules: { + "mocha/valid-test-description": ["warn", { pattern: "mypattern$", testNames: ["it", "specify", "test", "mytestname"], message: 'custom error message' }] }, ``` @@ -19,7 +23,8 @@ where: * `warn` is a rule error level (see [Configuring Rules](http://eslint.org/docs/user-guide/configuring#configuring-rules)) * `mypattern$` is a custom regular expression pattern to match test names against - * `["it", "specify", "test", "mytestname"]` is an array of custom test names + * `["it", "specify", "test", "mytestname"]` is an array of custom test names + * `custom error message` a custom error message to describe your pattern The following patterns are considered warnings (with the default rule configuration):