UNPKG

eslint-plugin-ui-testing

Version:

ESLint rules for UI testing tools WebdriverIO, Cypress, TestCafe, Playwright, Puppeteer

42 lines (41 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RULE_NAME = void 0; var utils_1 = require("../utils/utils"); exports.RULE_NAME = __filename.slice(__dirname.length + 1, -3); exports.default = (0, utils_1.createRule)({ name: exports.RULE_NAME, meta: { docs: { description: 'Disallow assertions in hooks', recommended: 'error', }, messages: { noAssertionsInHooks: 'Avoid using assertions in hooks', }, schema: [ { type: 'object', properties: { assertCommands: { type: 'array', items: [{ type: 'string' }], }, }, additionalProperties: false, }, ], type: 'problem', }, defaultOptions: [{ assertCommands: ['expect', 'expectAsync', 'assert'] }], create: function (context, _a) { var _b; var _c = _a[0].assertCommands, assertCommands = _c === void 0 ? ['expect', 'expectAsync', 'assert'] : _c; var commands = assertCommands.join('|'); return _b = {}, _b["CallExpression[callee.name=/^(before|after)(Each|All)$/] Identifier[name=/^" + commands + "$/]"] = function (node) { context.report({ node: node, messageId: 'noAssertionsInHooks' }); }, _b; }, });