🚫 This rule is disabled in the ✅ recommended
config.
This rule enforces the test descriptions to follow the desired format.
By default, the regular expression is configured to be "^should"
which requires test descriptions to start with "should".
Example of a custom rule configuration:
rules: {
"mocha/valid-test-title": ["warn", { pattern: "mypattern$", message: 'custom error message' }]
},
where:
warn
is a rule error level (see Configuring Rules)mypattern$
is a custom regular expression pattern to match test names againstcustom error message
a custom error message to describe your pattern
The following patterns are considered warnings (with the default rule configuration):
// bdd
it('does something', function () {});
specify('does something', function () {});
// tdd
test('does something', function () {});
These patterns would not be considered warnings:
// bdd
it('should respond to GET', function () {});
it('should do something');
specify('should respond to GET', function () {});
specify('should do something');
// tdd
test('should respond to GET', function () {});
test('should do something');