/
no-skipped-tests.js
37 lines (33 loc) · 1.16 KB
/
no-skipped-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
const createAstUtils = require('../util/ast');
module.exports = {
meta: {
docs: {
description: 'Disallow skipped tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-skipped-tests.md'
},
type: 'problem',
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
const options = { modifiers: [ 'skip' ], modifiersOnly: true };
const isTestCase = astUtils.buildIsTestCaseAnswerer(options);
const isDescribe = astUtils.buildIsDescribeAnswerer(options);
return {
CallExpression(node) {
if (isDescribe(node) || isTestCase(node)) {
const callee = node.callee;
const nodeToReport =
callee.type === 'MemberExpression' ?
callee.property :
callee;
context.report({
node: nodeToReport,
message: 'Unexpected skipped mocha test.'
});
}
}
};
}
};