eslint-plugin-jest 27.4.3 → 27.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,10 +51,9 @@ xtest('foo', () => {});
|
|
|
51
51
|
|
|
52
52
|
**titleMustBeString**
|
|
53
53
|
|
|
54
|
-
Titles for test blocks should always be a string
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
the `ignoreTypeOfDescribeName` option:
|
|
54
|
+
Titles for `describe`, `test`, and `it` blocks should always be a string; you
|
|
55
|
+
can disable this with the `ignoreTypeOfDescribeName` and `ignoreTypeOfTestName`
|
|
56
|
+
options.
|
|
58
57
|
|
|
59
58
|
Examples of **incorrect** code for this rule:
|
|
60
59
|
|
|
@@ -93,6 +92,18 @@ xdescribe(myFunction, () => {});
|
|
|
93
92
|
describe(6, function () {});
|
|
94
93
|
```
|
|
95
94
|
|
|
95
|
+
Examples of **correct** code when `ignoreTypeOfTestName` is `true`:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const myTestName = 'is a string';
|
|
99
|
+
|
|
100
|
+
it(String(/.+/), () => {});
|
|
101
|
+
it(myFunction, () => {});
|
|
102
|
+
it(myTestName, () => {});
|
|
103
|
+
xit(myFunction, () => {});
|
|
104
|
+
it(6, function () {});
|
|
105
|
+
```
|
|
106
|
+
|
|
96
107
|
**duplicatePrefix**
|
|
97
108
|
|
|
98
109
|
A `describe` / `test` block should not start with `duplicatePrefix`
|
package/lib/rules/valid-title.js
CHANGED
|
@@ -76,6 +76,10 @@ var _default = exports.default = (0, _utils2.createRule)({
|
|
|
76
76
|
type: 'boolean',
|
|
77
77
|
default: false
|
|
78
78
|
},
|
|
79
|
+
ignoreTypeOfTestName: {
|
|
80
|
+
type: 'boolean',
|
|
81
|
+
default: false
|
|
82
|
+
},
|
|
79
83
|
disallowedWords: {
|
|
80
84
|
type: 'array',
|
|
81
85
|
items: {
|
|
@@ -107,11 +111,13 @@ var _default = exports.default = (0, _utils2.createRule)({
|
|
|
107
111
|
defaultOptions: [{
|
|
108
112
|
ignoreSpaces: false,
|
|
109
113
|
ignoreTypeOfDescribeName: false,
|
|
114
|
+
ignoreTypeOfTestName: false,
|
|
110
115
|
disallowedWords: []
|
|
111
116
|
}],
|
|
112
117
|
create(context, [{
|
|
113
118
|
ignoreSpaces,
|
|
114
119
|
ignoreTypeOfDescribeName,
|
|
120
|
+
ignoreTypeOfTestName,
|
|
115
121
|
disallowedWords = [],
|
|
116
122
|
mustNotMatch,
|
|
117
123
|
mustMatch
|
|
@@ -133,7 +139,7 @@ var _default = exports.default = (0, _utils2.createRule)({
|
|
|
133
139
|
if (argument.type === _utils.AST_NODE_TYPES.BinaryExpression && doesBinaryExpressionContainStringNode(argument)) {
|
|
134
140
|
return;
|
|
135
141
|
}
|
|
136
|
-
if (
|
|
142
|
+
if (!(jestFnCall.type === 'describe' && ignoreTypeOfDescribeName || jestFnCall.type === 'test' && ignoreTypeOfTestName) && argument.type !== _utils.AST_NODE_TYPES.TemplateLiteral) {
|
|
137
143
|
context.report({
|
|
138
144
|
messageId: 'titleMustBeString',
|
|
139
145
|
loc: argument.loc
|