eslint-plugin-jest 26.4.0 → 26.4.1

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.
@@ -17,8 +17,6 @@ var _default = (0, _utils.createRule)({
17
17
  },
18
18
  messages: {
19
19
  missingFunction: 'Test is missing function argument',
20
- skippedTestSuite: 'Skipped test suite',
21
- skippedTest: 'Skipped test',
22
20
  pending: 'Call to pending()',
23
21
  pendingSuite: 'Call to pending() within test suite',
24
22
  pendingTest: 'Call to pending() within test',
@@ -34,14 +32,6 @@ var _default = (0, _utils.createRule)({
34
32
  let suiteDepth = 0;
35
33
  let testDepth = 0;
36
34
  return {
37
- 'CallExpression[callee.name="describe"]'() {
38
- suiteDepth++;
39
- },
40
-
41
- 'CallExpression[callee.name=/^(it|test)$/]'() {
42
- testDepth++;
43
- },
44
-
45
35
  'CallExpression[callee.name=/^(it|test)$/][arguments.length<2]'(node) {
46
36
  context.report({
47
37
  messageId: 'missingFunction',
@@ -50,35 +40,42 @@ var _default = (0, _utils.createRule)({
50
40
  },
51
41
 
52
42
  CallExpression(node) {
53
- const functionName = (0, _utils.getNodeName)(node.callee); // prevent duplicate warnings for it.each()()
43
+ const jestFnCall = (0, _utils.parseJestFnCall)(node, context.getScope());
44
+
45
+ if (!jestFnCall) {
46
+ return;
47
+ }
48
+
49
+ if (jestFnCall.type === 'describe') {
50
+ suiteDepth++;
51
+ }
52
+
53
+ if (jestFnCall.type === 'test') {
54
+ testDepth++;
55
+ }
56
+
57
+ if ( // the only jest functions that are with "x" are "xdescribe", "xtest", and "xit"
58
+ jestFnCall.name.startsWith('x') || jestFnCall.members.some(s => (0, _utils.getAccessorValue)(s) === 'skip')) {
59
+ context.report({
60
+ messageId: jestFnCall.type === 'describe' ? 'disabledSuite' : 'disabledTest',
61
+ node
62
+ });
63
+ }
64
+ },
54
65
 
55
- if (node.callee.type === 'CallExpression') {
66
+ 'CallExpression:exit'(node) {
67
+ const jestFnCall = (0, _utils.parseJestFnCall)(node, context.getScope());
68
+
69
+ if (!jestFnCall) {
56
70
  return;
57
71
  }
58
72
 
59
- switch (functionName) {
60
- case 'describe.skip.each':
61
- case 'xdescribe.each':
62
- case 'describe.skip':
63
- context.report({
64
- messageId: 'skippedTestSuite',
65
- node
66
- });
67
- break;
68
-
69
- case 'it.skip':
70
- case 'it.concurrent.skip':
71
- case 'test.skip':
72
- case 'test.concurrent.skip':
73
- case 'it.skip.each':
74
- case 'test.skip.each':
75
- case 'xit.each':
76
- case 'xtest.each':
77
- context.report({
78
- messageId: 'skippedTest',
79
- node
80
- });
81
- break;
73
+ if (jestFnCall.type === 'describe') {
74
+ suiteDepth--;
75
+ }
76
+
77
+ if (jestFnCall.type === 'test') {
78
+ testDepth--;
82
79
  }
83
80
  },
84
81
 
@@ -103,28 +100,6 @@ var _default = (0, _utils.createRule)({
103
100
  node
104
101
  });
105
102
  }
106
- },
107
-
108
- 'CallExpression[callee.name="xdescribe"]'(node) {
109
- context.report({
110
- messageId: 'disabledSuite',
111
- node
112
- });
113
- },
114
-
115
- 'CallExpression[callee.name=/^(xit|xtest)$/]'(node) {
116
- context.report({
117
- messageId: 'disabledTest',
118
- node
119
- });
120
- },
121
-
122
- 'CallExpression[callee.name="describe"]:exit'() {
123
- suiteDepth--;
124
- },
125
-
126
- 'CallExpression[callee.name=/^(it|test)$/]:exit'() {
127
- testDepth--;
128
103
  }
129
104
 
130
105
  };
@@ -64,7 +64,7 @@ const determineJestFnType = name => {
64
64
  return 'unknown';
65
65
  };
66
66
 
67
- const ValidJestFnCallChains = ['afterAll', 'afterEach', 'beforeAll', 'beforeEach', 'describe', 'describe.each', 'describe.only', 'describe.only.each', 'describe.skip', 'describe.skip.each', 'fdescribe', 'fdescribe.each', 'xdescribe', 'xdescribe.each', 'it', 'it.concurrent', 'it.concurrent.each', 'it.concurrent.only.each', 'it.concurrent.skip.each', 'it.each', 'it.failing', 'it.only', 'it.only.each', 'it.skip', 'it.skip.each', 'it.todo', 'fit', 'fit.each', 'xit', 'xit.each', 'test', 'test.concurrent', 'test.concurrent.each', 'test.concurrent.only.each', 'test.concurrent.skip.each', 'test.each', 'test.only', 'test.only.each', 'test.skip', 'test.skip.each', 'test.todo', 'xtest', 'xtest.each', // todo: check if actually valid (not in docs)
67
+ const ValidJestFnCallChains = ['afterAll', 'afterEach', 'beforeAll', 'beforeEach', 'describe', 'describe.each', 'describe.only', 'describe.only.each', 'describe.skip', 'describe.skip.each', 'fdescribe', 'fdescribe.each', 'xdescribe', 'xdescribe.each', 'it', 'it.concurrent', 'it.concurrent.each', 'it.concurrent.only.each', 'it.concurrent.skip.each', 'it.each', 'it.failing', 'it.only', 'it.only.each', 'it.only.failing', 'it.skip', 'it.skip.each', 'it.skip.failing', 'it.todo', 'fit', 'fit.each', 'fit.failing', 'xit', 'xit.each', 'xit.failing', 'test', 'test.concurrent', 'test.concurrent.each', 'test.concurrent.only.each', 'test.concurrent.skip.each', 'test.each', 'test.failing', 'test.only', 'test.only.each', 'test.only.failing', 'test.skip', 'test.skip.each', 'test.skip.failing', 'test.todo', 'xtest', 'xtest.each', 'xtest.failing', // todo: check if actually valid (not in docs)
68
68
  'test.concurrent.skip', 'test.concurrent.only', 'it.concurrent.skip', 'it.concurrent.only'];
69
69
 
70
70
  const parseJestFnCall = (node, scope) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-jest",
3
- "version": "26.4.0",
3
+ "version": "26.4.1",
4
4
  "description": "ESLint rules for Jest",
5
5
  "keywords": [
6
6
  "eslint",