diff --git a/eslint.config.mjs b/eslint.config.mjs index 9ef0abd8a..6fba66b27 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -16,7 +16,6 @@ export default [ { ignores: ['test/data/output', 'lib/css2xpath/*'], }, - ...compat.extends('airbnb-base'), { languageOptions: { globals: { @@ -24,7 +23,7 @@ export default [ }, ecmaVersion: 2020, - sourceType: 'commonjs', + sourceType: 'module', }, rules: { diff --git a/lib/heal.js b/lib/heal.js index 7c21a47f8..0c5280dca 100644 --- a/lib/heal.js +++ b/lib/heal.js @@ -1,64 +1,64 @@ -const debug = require('debug')('codeceptjs:heal'); -const colors = require('chalk'); -const Container = require('./container'); -const recorder = require('./recorder'); -const output = require('./output'); -const event = require('./event'); +const debug = require('debug')('codeceptjs:heal') +const colors = require('chalk') +const Container = require('./container') +const recorder = require('./recorder') +const output = require('./output') +const event = require('./event') /** * @class */ class Heal { constructor() { - this.recipes = {}; - this.fixes = []; - this.prepareFns = []; - this.contextName = null; - this.numHealed = 0; + this.recipes = {} + this.fixes = [] + this.prepareFns = [] + this.contextName = null + this.numHealed = 0 } clear() { - this.recipes = {}; - this.fixes = []; - this.prepareFns = []; - this.contextName = null; - this.numHealed = 0; + this.recipes = {} + this.fixes = [] + this.prepareFns = [] + this.contextName = null + this.numHealed = 0 } addRecipe(name, opts = {}) { - if (!opts.priority) opts.priority = 0; + if (!opts.priority) opts.priority = 0 - if (!opts.fn) throw new Error(`Recipe ${name} should have a function 'fn' to execute`); + if (!opts.fn) throw new Error(`Recipe ${name} should have a function 'fn' to execute`) - this.recipes[name] = opts; + this.recipes[name] = opts } connectToEvents() { event.dispatcher.on(event.suite.before, suite => { - this.contextName = suite.title; - }); + this.contextName = suite.title + }) event.dispatcher.on(event.test.started, test => { - this.contextName = test.fullTitle(); - }); + this.contextName = test.fullTitle() + }) event.dispatcher.on(event.test.finished, () => { - this.contextName = null; - }); + this.contextName = null + }) } hasCorrespondingRecipes(step) { - return matchRecipes(this.recipes, this.contextName).filter(r => !r.steps || r.steps.includes(step.name)).length > 0; + return matchRecipes(this.recipes, this.contextName).filter(r => !r.steps || r.steps.includes(step.name)).length > 0 } async getCodeSuggestions(context) { - const suggestions = []; - const recipes = matchRecipes(this.recipes, this.contextName); + const suggestions = [] + const recipes = matchRecipes(this.recipes, this.contextName) - debug('Recipes', recipes); + debug('Recipes', recipes) - const currentOutputLevel = output.level(); - output.level(0); + const currentOutputLevel = output.level() + output.level(0) for (const [property, prepareFn] of Object.entries( recipes @@ -66,60 +66,60 @@ class Heal { .filter(p => !!p) .reduce((acc, obj) => ({ ...acc, ...obj }), {}), )) { - if (!prepareFn) continue; + if (!prepareFn) continue - if (context[property]) continue; - context[property] = await prepareFn(Container.support()); + if (context[property]) continue + context[property] = await prepareFn(Container.support()) } - output.level(currentOutputLevel); + output.level(currentOutputLevel) for (const recipe of recipes) { - let snippets = await recipe.fn(context); - if (!Array.isArray(snippets)) snippets = [snippets]; + let snippets = await recipe.fn(context) + if (!Array.isArray(snippets)) snippets = [snippets] suggestions.push({ name: recipe.name, snippets, - }); + }) } - return suggestions.filter(s => !isBlank(s.snippets)); + return suggestions.filter(s => !isBlank(s.snippets)) } async healStep(failedStep, error, failureContext = {}) { - output.debug(`Trying to heal ${failedStep.toCode()} step`); + output.debug(`Trying to heal ${failedStep.toCode()} step`) Object.assign(failureContext, { error, step: failedStep, prevSteps: failureContext?.test?.steps?.slice(0, -1) || [], - }); + }) - const suggestions = await this.getCodeSuggestions(failureContext); + const suggestions = await this.getCodeSuggestions(failureContext) if (suggestions.length === 0) { - debug('No healing suggestions found'); - throw error; + debug('No healing suggestions found') + throw error } - output.debug(`Received ${suggestions.length} suggestion${suggestions.length === 1 ? '' : 's'}`); + output.debug(`Received ${suggestions.length} suggestion${suggestions.length === 1 ? '' : 's'}`) - debug(suggestions); + debug(suggestions) for (const suggestion of suggestions) { for (const codeSnippet of suggestion.snippets) { try { - debug('Executing', codeSnippet); + debug('Executing', codeSnippet) recorder.catch(e => { - debug(e); - }); + debug(e) + }) if (typeof codeSnippet === 'string') { - const I = Container.support('I'); - await eval(codeSnippet); // eslint-disable-line + const I = Container.support('I') + await eval(codeSnippet) } else if (typeof codeSnippet === 'function') { - await codeSnippet(Container.support()); + await codeSnippet(Container.support()) } this.fixes.push({ @@ -127,44 +127,44 @@ class Heal { test: failureContext?.test, step: failedStep, snippet: codeSnippet, - }); + }) - recorder.add('healed', () => output.print(colors.bold.green(` Code healed successfully by ${suggestion.name}`), colors.gray('(no errors thrown)'))); - this.numHealed++; + recorder.add('healed', () => output.print(colors.bold.green(` Code healed successfully by ${suggestion.name}`), colors.gray('(no errors thrown)'))) + this.numHealed++ // recorder.session.restore(); - return; + return } catch (err) { - debug('Failed to execute code', err); - recorder.ignoreErr(err); // healing did not help - recorder.catchWithoutStop(err); - await recorder.promise(); // wait for all promises to resolve + debug('Failed to execute code', err) + recorder.ignoreErr(err) // healing did not help + recorder.catchWithoutStop(err) + await recorder.promise() // wait for all promises to resolve } } } - output.debug(`Couldn't heal the code for ${failedStep.toCode()}`); - recorder.throw(error); + output.debug(`Couldn't heal the code for ${failedStep.toCode()}`) + recorder.throw(error) } static setDefaultHealers() { - require('./template/heal'); + require('./template/heal') } } -const heal = new Heal(); +const heal = new Heal() -module.exports = heal; +module.exports = heal function matchRecipes(recipes, contextName) { return Object.entries(recipes) .filter(([, recipe]) => !contextName || !recipe.grep || new RegExp(recipe.grep).test(contextName)) .sort(([, a], [, b]) => a.priority - b.priority) .map(([name, recipe]) => { - recipe.name = name; - return recipe; + recipe.name = name + return recipe }) - .filter(r => !!r.fn); + .filter(r => !!r.fn) } function isBlank(value) { - return value == null || (Array.isArray(value) && value.length === 0) || (typeof value === 'object' && Object.keys(value).length === 0) || (typeof value === 'string' && value.trim() === ''); + return value == null || (Array.isArray(value) && value.length === 0) || (typeof value === 'object' && Object.keys(value).length === 0) || (typeof value === 'string' && value.trim() === '') } diff --git a/lib/helper/Playwright.js b/lib/helper/Playwright.js index c40365c54..29238c8f0 100644 --- a/lib/helper/Playwright.js +++ b/lib/helper/Playwright.js @@ -2182,7 +2182,6 @@ class Playwright extends Helper { let chunked = chunkArray(props, values.length) chunked = chunked.filter(val => { for (let i = 0; i < val.length; ++i) { - // eslint-disable-next-line eqeqeq if (val[i] != values[i]) return false } return true @@ -2451,7 +2450,7 @@ class Playwright extends Helper { waiter = context.waitForFunction(valueFn, [locator.value], { timeout: waitTimeout }) } else { const enabledFn = function ([locator, $XPath]) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => !el.disabled).length > 0 } waiter = context.waitForFunction(enabledFn, [locator.value, $XPath.toString()], { timeout: waitTimeout }) @@ -2477,7 +2476,7 @@ class Playwright extends Helper { waiter = context.waitForFunction(valueFn, [locator.value], { timeout: waitTimeout }) } else { const disabledFn = function ([locator, $XPath]) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => el.disabled).length > 0 } waiter = context.waitForFunction(disabledFn, [locator.value, $XPath.toString()], { timeout: waitTimeout }) @@ -2503,7 +2502,7 @@ class Playwright extends Helper { waiter = context.waitForFunction(valueFn, [locator.value, value], { timeout: waitTimeout }) } else { const valueFn = function ([locator, $XPath, value]) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => (el.value || '').indexOf(value) !== -1).length > 0 } waiter = context.waitForFunction(valueFn, [locator.value, $XPath.toString(), value], { @@ -2537,7 +2536,7 @@ class Playwright extends Helper { waiter = context.waitForFunction(visibleFn, [locator.value, num], { timeout: waitTimeout }) } else { const visibleFn = function ([locator, $XPath, num]) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => el.offsetParent !== null).length === num } waiter = context.waitForFunction(visibleFn, [locator.value, $XPath.toString(), num], { @@ -2771,7 +2770,7 @@ class Playwright extends Helper { if (locator.isXPath()) { return contextObject.waitForFunction( ([locator, text, $XPath]) => { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) const el = $XPath(null, locator) if (!el.length) return false return el[0].innerText.indexOf(text) > -1 @@ -2975,7 +2974,7 @@ class Playwright extends Helper { } } else { const visibleFn = function ([locator, $XPath]) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).length === 0 } waiter = context.waitForFunction(visibleFn, [locator.value, $XPath.toString()], { timeout: waitTimeout }) @@ -3214,7 +3213,6 @@ class Playwright extends Helper { } for (const i in this.requests) { - // eslint-disable-next-line no-prototype-builtins if (this.requests.hasOwnProperty(i)) { const request = this.requests[i] diff --git a/lib/helper/Protractor.js b/lib/helper/Protractor.js index bcdcc00af..d547ff62e 100644 --- a/lib/helper/Protractor.js +++ b/lib/helper/Protractor.js @@ -1054,7 +1054,7 @@ class Protractor extends Helper { const stream = fs.createWriteStream(outputFile) stream.write(Buffer.from(png, 'base64')) stream.end() - return new Promise(resolve => stream.on('finish', resolve)) // eslint-disable-line no-promise-executor-return + return new Promise(resolve => stream.on('finish', resolve)) } const res = await this._locate(locator) @@ -1077,7 +1077,7 @@ class Protractor extends Helper { const stream = fs.createWriteStream(outputFile) stream.write(Buffer.from(png, 'base64')) stream.end() - return new Promise(resolve => stream.on('finish', resolve)) // eslint-disable-line no-promise-executor-return + return new Promise(resolve => stream.on('finish', resolve)) } if (!fullPage) { diff --git a/lib/helper/Puppeteer.js b/lib/helper/Puppeteer.js index e35d12a9d..ce65db079 100644 --- a/lib/helper/Puppeteer.js +++ b/lib/helper/Puppeteer.js @@ -1698,7 +1698,7 @@ class Puppeteer extends Helper { async executeAsyncScript(...args) { const asyncFn = function () { const args = Array.from(arguments) - const fn = eval(`(${args.shift()})`) // eslint-disable-line no-eval + const fn = eval(`(${args.shift()})`) return new Promise(done => { args.push(done) fn.apply(null, args) @@ -1838,7 +1838,6 @@ class Puppeteer extends Helper { let chunked = chunkArray(props, values.length) chunked = chunked.filter(val => { for (let i = 0; i < val.length; ++i) { - // eslint-disable-next-line eqeqeq if (val[i] != values[i]) return false } return true @@ -2036,7 +2035,7 @@ class Puppeteer extends Helper { waiter = context.waitForFunction(enabledFn, { timeout: waitTimeout }, locator.value) } else { const enabledFn = function (locator, $XPath) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => !el.disabled).length > 0 } waiter = context.waitForFunction(enabledFn, { timeout: waitTimeout }, locator.value, $XPath.toString()) @@ -2066,7 +2065,7 @@ class Puppeteer extends Helper { waiter = context.waitForFunction(valueFn, { timeout: waitTimeout }, locator.value, value) } else { const valueFn = function (locator, $XPath, value) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => (el.value || '').indexOf(value) !== -1).length > 0 } waiter = context.waitForFunction(valueFn, { timeout: waitTimeout }, locator.value, $XPath.toString(), value) @@ -2097,7 +2096,7 @@ class Puppeteer extends Helper { waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value, num) } else { const visibleFn = function (locator, $XPath, num) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).filter(el => el.offsetParent !== null).length === num } waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value, $XPath.toString(), num) @@ -2308,7 +2307,7 @@ class Puppeteer extends Helper { if (locator.isXPath()) { waiter = contextObject.waitForFunction( (locator, text, $XPath) => { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) const el = $XPath(null, locator) if (!el.length) return false return el[0].innerText.indexOf(text) > -1 @@ -2456,7 +2455,7 @@ class Puppeteer extends Helper { waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value) } else { const visibleFn = function (locator, $XPath) { - eval($XPath) // eslint-disable-line no-eval + eval($XPath) return $XPath(null, locator).length === 0 } waiter = context.waitForFunction(visibleFn, { timeout: waitTimeout }, locator.value, $XPath.toString()) diff --git a/lib/helper/TestCafe.js b/lib/helper/TestCafe.js index e7da647ce..76bf97d01 100644 --- a/lib/helper/TestCafe.js +++ b/lib/helper/TestCafe.js @@ -382,7 +382,6 @@ class TestCafe extends Helper { * {{> refreshPage }} */ async refreshPage() { - // eslint-disable-next-line no-restricted-globals return this.t.eval(() => location.reload(true), { boundTestRun: this.t }).catch(mapError) } @@ -562,7 +561,6 @@ class TestCafe extends Helper { await this.t.click(optEl).catch(mapError) continue } - // eslint-disable-next-line no-empty } catch (err) {} try { @@ -571,7 +569,6 @@ class TestCafe extends Helper { if (await optEl.count) { await this.t.click(optEl).catch(mapError) } - // eslint-disable-next-line no-empty } catch (err) {} } } diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index d180739e2..efd6edf69 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1589,7 +1589,6 @@ class WebDriver extends Helper { let chunked = chunkArray(props, values.length) chunked = chunked.filter(val => { for (let i = 0; i < val.length; ++i) { - // eslint-disable-next-line eqeqeq if (val[i] != values[i]) return false } return true diff --git a/lib/helper/testcafe/testcafe-utils.js b/lib/helper/testcafe/testcafe-utils.js index b5a772c8f..429eec884 100644 --- a/lib/helper/testcafe/testcafe-utils.js +++ b/lib/helper/testcafe/testcafe-utils.js @@ -1,15 +1,15 @@ -const { ClientFunction } = require('testcafe'); +const { ClientFunction } = require('testcafe') -const assert = require('assert'); -const fs = require('fs'); -const path = require('path'); -const { getParamNames } = require('../../utils'); +const assert = require('assert') +const fs = require('fs') +const path = require('path') +const { getParamNames } = require('../../utils') const createTestFile = () => { - assert(global.output_dir, 'global.output_dir must be set'); + assert(global.output_dir, 'global.output_dir must be set') - const testFile = path.join(global.output_dir, `${Date.now()}_test.js`); - const testControllerHolderDir = __dirname.replace(/\\/g, '/'); + const testFile = path.join(global.output_dir, `${Date.now()}_test.js`) + const testControllerHolderDir = __dirname.replace(/\\/g, '/') fs.writeFileSync( testFile, @@ -17,40 +17,39 @@ const createTestFile = () => { fixture("fixture")\n test\n ("test", testControllerHolder.capture)`, - ); + ) - return testFile; -}; + return testFile +} // TODO Better error mapping (actual, expected) const mapError = testcafeError => { // console.log('TODO map error better', JSON.stringify(testcafeError, null, 2)); if (testcafeError.errMsg) { - throw new Error(testcafeError.errMsg); + throw new Error(testcafeError.errMsg) } - const errorInfo = `${testcafeError.callsite ? JSON.stringify(testcafeError.callsite) : ''} ${testcafeError.apiFnChain || JSON.stringify(testcafeError)}`; - throw new Error(`TestCafe Error: ${errorInfo}`); -}; + const errorInfo = `${testcafeError.callsite ? JSON.stringify(testcafeError.callsite) : ''} ${testcafeError.apiFnChain || JSON.stringify(testcafeError)}` + throw new Error(`TestCafe Error: ${errorInfo}`) +} function createClientFunction(func, args) { if (!args || !args.length) { - return ClientFunction(func); + return ClientFunction(func) } - const paramNames = getParamNames(func); - const dependencies = {}; - paramNames.forEach((param, i) => (dependencies[param] = args[i])); + const paramNames = getParamNames(func) + const dependencies = {} + paramNames.forEach((param, i) => (dependencies[param] = args[i])) - return ClientFunction(getFuncBody(func), { dependencies }); + return ClientFunction(getFuncBody(func), { dependencies }) } function getFuncBody(func) { - let fnStr = func.toString(); - const arrowIndex = fnStr.indexOf('=>'); + let fnStr = func.toString() + const arrowIndex = fnStr.indexOf('=>') if (arrowIndex >= 0) { - fnStr = fnStr.slice(arrowIndex + 2); + fnStr = fnStr.slice(arrowIndex + 2) - // eslint-disable-next-line no-eval - return eval(`() => ${fnStr}`); + return eval(`() => ${fnStr}`) } // TODO: support general functions } @@ -59,4 +58,4 @@ module.exports = { createTestFile, mapError, createClientFunction, -}; +} diff --git a/lib/mocha/hooks.js b/lib/mocha/hooks.js index ad0695d77..3c9aa7d4d 100644 --- a/lib/mocha/hooks.js +++ b/lib/mocha/hooks.js @@ -1,4 +1,3 @@ -/* eslint-disable dot-notation */ const event = require('../event') class Hook { diff --git a/lib/pause.js b/lib/pause.js index 7f5830480..65733ecff 100644 --- a/lib/pause.js +++ b/lib/pause.js @@ -1,59 +1,59 @@ -const colors = require('chalk'); -const readline = require('readline'); -const ora = require('ora-classic'); -const debug = require('debug')('codeceptjs:pause'); - -const container = require('./container'); -const history = require('./history'); -const store = require('./store'); -const aiAssistant = require('./ai'); -const recorder = require('./recorder'); -const event = require('./event'); -const output = require('./output'); -const { methodsOfObject } = require('./utils'); +const colors = require('chalk') +const readline = require('readline') +const ora = require('ora-classic') +const debug = require('debug')('codeceptjs:pause') + +const container = require('./container') +const history = require('./history') +const store = require('./store') +const aiAssistant = require('./ai') +const recorder = require('./recorder') +const event = require('./event') +const output = require('./output') +const { methodsOfObject } = require('./utils') // npm install colors -let rl; -let nextStep; -let finish; -let next; -let registeredVariables = {}; +let rl +let nextStep +let finish +let next +let registeredVariables = {} /** * Pauses test execution and starts interactive shell * @param {Object} [passedObject] */ const pause = function (passedObject = {}) { - if (store.dryRun) return; + if (store.dryRun) return - next = false; + next = false // add listener to all next steps to provide next() functionality event.dispatcher.on(event.step.after, () => { recorder.add('Start next pause session', () => { - if (!next) return; - return pauseSession(); - }); - }); - recorder.add('Start new session', () => pauseSession(passedObject)); -}; + if (!next) return + return pauseSession() + }) + }) + recorder.add('Start new session', () => pauseSession(passedObject)) +} function pauseSession(passedObject = {}) { - registeredVariables = passedObject; - recorder.session.start('pause'); + registeredVariables = passedObject + recorder.session.start('pause') if (!next) { - let vars = Object.keys(registeredVariables).join(', '); - if (vars) vars = `(vars: ${vars})`; + let vars = Object.keys(registeredVariables).join(', ') + if (vars) vars = `(vars: ${vars})` - output.print(colors.yellow(' Interactive shell started')); - output.print(colors.yellow(' Use JavaScript syntax to try steps in action')); - output.print(colors.yellow(` - Press ${colors.bold('ENTER')} to run the next step`)); - output.print(colors.yellow(` - Press ${colors.bold('TAB')} twice to see all available commands`)); - output.print(colors.yellow(` - Type ${colors.bold('exit')} + Enter to exit the interactive shell`)); - output.print(colors.yellow(` - Prefix ${colors.bold('=>')} to run js commands ${colors.bold(vars)}`)); + output.print(colors.yellow(' Interactive shell started')) + output.print(colors.yellow(' Use JavaScript syntax to try steps in action')) + output.print(colors.yellow(` - Press ${colors.bold('ENTER')} to run the next step`)) + output.print(colors.yellow(` - Press ${colors.bold('TAB')} twice to see all available commands`)) + output.print(colors.yellow(` - Type ${colors.bold('exit')} + Enter to exit the interactive shell`)) + output.print(colors.yellow(` - Prefix ${colors.bold('=>')} to run js commands ${colors.bold(vars)}`)) if (aiAssistant.isEnabled) { - output.print(colors.blue(` ${colors.bold('AI is enabled! (experimental)')} Write what you want and make AI run it`)); - output.print(colors.blue(' Please note, only HTML fragments with interactive elements are sent to AI provider')); - output.print(colors.blue(' Ideas: ask it to fill forms for you or to click')); + output.print(colors.blue(` ${colors.bold('AI is enabled! (experimental)')} Write what you want and make AI run it`)) + output.print(colors.blue(' Please note, only HTML fragments with interactive elements are sent to AI provider')) + output.print(colors.blue(' Ideas: ask it to fill forms for you or to click')) } } @@ -64,155 +64,152 @@ function pauseSession(passedObject = {}) { completer, history: history.load(), historySize: 50, // Adjust the history size as needed - }); + }) - rl.on('line', parseInput); + rl.on('line', parseInput) rl.on('close', () => { - if (!next) console.log('Exiting interactive shell....'); - }); + if (!next) console.log('Exiting interactive shell....') + }) return new Promise(resolve => { - finish = resolve; - // eslint-disable-next-line - return askForStep(); - }); + finish = resolve + return askForStep() + }) } -/* eslint-disable */ async function parseInput(cmd) { - rl.pause(); - next = false; - recorder.session.start('pause'); - if (cmd === '') next = true; + rl.pause() + next = false + recorder.session.start('pause') + if (cmd === '') next = true if (!cmd || cmd === 'resume' || cmd === 'exit') { - finish(); - recorder.session.restore(); - rl.close(); - history.save(); - return nextStep(); + finish() + recorder.session.restore() + rl.close() + history.save() + return nextStep() } for (const k of Object.keys(registeredVariables)) { - eval(`var ${k} = registeredVariables['${k}'];`); + eval(`var ${k} = registeredVariables['${k}'];`) } - let executeCommand = Promise.resolve(); + let executeCommand = Promise.resolve() const getCmd = () => { - debug('Command:', cmd); - return cmd; - }; - - let isCustomCommand = false; - let lastError = null; - let isAiCommand = false; - let $res; + debug('Command:', cmd) + return cmd + } + + let isCustomCommand = false + let lastError = null + let isAiCommand = false + let $res try { - const locate = global.locate; // enable locate in this context + const locate = global.locate // enable locate in this context - const I = container.support('I'); + const I = container.support('I') if (cmd.trim().startsWith('=>')) { - isCustomCommand = true; - cmd = cmd.trim().substring(2, cmd.length); + isCustomCommand = true + cmd = cmd.trim().substring(2, cmd.length) } else if (aiAssistant.isEnabled && cmd.trim() && !cmd.match(/^\w+\(/) && cmd.includes(' ')) { - const currentOutputLevel = output.level(); - output.level(0); - const res = I.grabSource(); - isAiCommand = true; + const currentOutputLevel = output.level() + output.level(0) + const res = I.grabSource() + isAiCommand = true executeCommand = executeCommand.then(async () => { try { - const html = await res; - await aiAssistant.setHtmlContext(html); + const html = await res + await aiAssistant.setHtmlContext(html) } catch (err) { - output.print(output.styles.error(' ERROR '), "Can't get HTML context", err.stack); - return; + output.print(output.styles.error(' ERROR '), "Can't get HTML context", err.stack) + return } finally { - output.level(currentOutputLevel); + output.level(currentOutputLevel) } - const spinner = ora('Processing AI request...').start(); - cmd = await aiAssistant.writeSteps(cmd); - spinner.stop(); - output.print(''); - output.print(colors.blue(aiAssistant.getResponse())); - output.print(''); - return cmd; - }); + const spinner = ora('Processing AI request...').start() + cmd = await aiAssistant.writeSteps(cmd) + spinner.stop() + output.print('') + output.print(colors.blue(aiAssistant.getResponse())) + output.print('') + return cmd + }) } else { - cmd = `I.${cmd}`; + cmd = `I.${cmd}` } executeCommand = executeCommand .then(async () => { - const cmd = getCmd(); - if (!cmd) return; - return eval(cmd); + const cmd = getCmd() + if (!cmd) return + return eval(cmd) }) .catch(err => { - debug(err); - if (isAiCommand) return; - if (!lastError) output.print(output.styles.error(' ERROR '), err.message); - debug(err.stack); + debug(err) + if (isAiCommand) return + if (!lastError) output.print(output.styles.error(' ERROR '), err.message) + debug(err.stack) - lastError = err.message; - }); + lastError = err.message + }) - const val = await executeCommand; + const val = await executeCommand if (isCustomCommand) { - if (val !== undefined) console.log('Result', '$res=', val); - $res = val; + if (val !== undefined) console.log('Result', '$res=', val) + $res = val } if (cmd?.startsWith('I.see') || cmd?.startsWith('I.dontSee')) { - output.print(output.styles.success(' OK '), cmd); + output.print(output.styles.success(' OK '), cmd) } if (cmd?.startsWith('I.grab')) { - output.print(output.styles.debug(val)); + output.print(output.styles.debug(val)) } - history.push(cmd); // add command to history when successful + history.push(cmd) // add command to history when successful } catch (err) { - if (!lastError) output.print(output.styles.error(' ERROR '), err.message); - lastError = err.message; + if (!lastError) output.print(output.styles.error(' ERROR '), err.message) + lastError = err.message } recorder.session.catch(err => { - const msg = err.cliMessage ? err.cliMessage() : err.message; + const msg = err.cliMessage ? err.cliMessage() : err.message // pop latest command from history because it failed - history.pop(); - - if (isAiCommand) return; - if (!lastError) output.print(output.styles.error(' FAIL '), msg); - lastError = err.message; - }); - recorder.add('ask for next step', askForStep); - nextStep(); + history.pop() + + if (isAiCommand) return + if (!lastError) output.print(output.styles.error(' FAIL '), msg) + lastError = err.message + }) + recorder.add('ask for next step', askForStep) + nextStep() } -/* eslint-enable */ function askForStep() { return new Promise(resolve => { - nextStep = resolve; - rl.setPrompt(' I.', 3); - rl.resume(); - rl.prompt([false]); - }); + nextStep = resolve + rl.setPrompt(' I.', 3) + rl.resume() + rl.prompt([false]) + }) } function completer(line) { - const I = container.support('I'); - const completions = methodsOfObject(I); + const I = container.support('I') + const completions = methodsOfObject(I) const hits = completions.filter(c => { if (c.indexOf(line) === 0) { - return c; + return c } - return null; - }); - return [hits && hits.length ? hits : completions, line]; + return null + }) + return [hits && hits.length ? hits : completions, line] } function registerVariable(name, value) { - registeredVariables[name] = value; + registeredVariables[name] = value } -module.exports = pause; +module.exports = pause -module.exports.registerVariable = registerVariable; +module.exports.registerVariable = registerVariable diff --git a/lib/utils.js b/lib/utils.js index ae1a44e3d..5698f1464 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -190,7 +190,7 @@ module.exports.test = { return function (key) { if (!fs.existsSync(dataFile)) { const waitTill = new Date(new Date().getTime() + 1 * 1000) // wait for one sec for file to be created - while (waitTill > new Date()) {} // eslint-disable-line no-empty + while (waitTill > new Date()) {} } if (!fs.existsSync(dataFile)) { throw new Error('Data file was not created in time') diff --git a/package.json b/package.json index 633b6bed6..8fff055b3 100644 --- a/package.json +++ b/package.json @@ -136,8 +136,7 @@ "chai-subset": "1.6.0", "documentation": "14.0.3", "electron": "33.2.1", - "eslint": "^8.57.1", - "eslint-config-airbnb-base": "15.0.0", + "eslint": "^9.17.0", "eslint-plugin-import": "2.31.0", "eslint-plugin-mocha": "10.5.0", "expect": "29.7.0", diff --git a/test/data/sandbox/codecept.workers-custom-output-folder-name.conf.js b/test/data/sandbox/codecept.workers-custom-output-folder-name.conf.js index 4371177ff..10bab529d 100644 --- a/test/data/sandbox/codecept.workers-custom-output-folder-name.conf.js +++ b/test/data/sandbox/codecept.workers-custom-output-folder-name.conf.js @@ -9,8 +9,7 @@ exports.config = { }, }, include: {}, - // eslint-disable-next-line no-empty-function async bootstrap() {}, mocha: {}, name: 'sandbox', -}; +} diff --git a/test/data/sandbox/configs/run-rerun/first_ftest.js b/test/data/sandbox/configs/run-rerun/first_ftest.js index 971961909..6036d1370 100644 --- a/test/data/sandbox/configs/run-rerun/first_ftest.js +++ b/test/data/sandbox/configs/run-rerun/first_ftest.js @@ -1,16 +1,15 @@ -/* eslint-disable radix */ -Feature('Run Rerun - Command'); +Feature('Run Rerun - Command') Scenario('@RunRerun - Fail all attempt', ({ I }) => { - I.printMessage('RunRerun'); - throw new Error('Test Error'); -}); + I.printMessage('RunRerun') + throw new Error('Test Error') +}) Scenario('@RunRerun - fail second test', ({ I }) => { - I.printMessage('RunRerun'); - process.env.FAIL_ATTEMPT = parseInt(process.env.FAIL_ATTEMPT) + 1; - console.log(process.env.FAIL_ATTEMPT); + I.printMessage('RunRerun') + process.env.FAIL_ATTEMPT = parseInt(process.env.FAIL_ATTEMPT) + 1 + console.log(process.env.FAIL_ATTEMPT) if (process.env.FAIL_ATTEMPT === '2') { - throw new Error('Test Error'); + throw new Error('Test Error') } -}); +}) diff --git a/test/data/sandbox/eventHandlers.js b/test/data/sandbox/eventHandlers.js index 3dad5b819..f8e18261f 100644 --- a/test/data/sandbox/eventHandlers.js +++ b/test/data/sandbox/eventHandlers.js @@ -1,9 +1,9 @@ -let event; +let event try { - require.resolve('../../../lib'); - event = require('../../../lib').event; + require.resolve('../../../lib') + event = require('../../../lib').event } catch (err) { - event = require('/codecept/lib').event; // eslint-disable-line + event = require('/codecept/lib').event } const eventTypes = [ @@ -22,32 +22,32 @@ const eventTypes = [ event.test.passed, event.test.failed, event.test.after, -]; +] -let eventRecorder = []; -let eventTypeCounter = {}; +let eventRecorder = [] +let eventTypeCounter = {} const options = { logToConsole: false, -}; +} -const newEventHandler = (name) => { +const newEventHandler = name => { event.dispatcher.on(name, () => { - eventRecorder.push(name); - eventTypeCounter[name] = (eventTypeCounter[name] || 0) + 1; + eventRecorder.push(name) + eventTypeCounter[name] = (eventTypeCounter[name] || 0) + 1 if (options.logToConsole) { - console.log(`Event:${name}`); + console.log(`Event:${name}`) } - }); -}; + }) +} -eventTypes.forEach(name => newEventHandler(name)); +eventTypes.forEach(name => newEventHandler(name)) module.exports = { events: eventRecorder, counter: eventTypeCounter, clearEvents: () => { - eventRecorder = []; - eventTypeCounter = {}; + eventRecorder = [] + eventTypeCounter = {} }, - setConsoleLogging: on => options.logToConsole = !!on, -}; + setConsoleLogging: on => (options.logToConsole = !!on), +} diff --git a/test/data/sandbox/features/step_definitions/my_steps.de.js b/test/data/sandbox/features/step_definitions/my_steps.de.js index 0fdc12f1c..98d1e549f 100644 --- a/test/data/sandbox/features/step_definitions/my_steps.de.js +++ b/test/data/sandbox/features/step_definitions/my_steps.de.js @@ -1,17 +1,17 @@ -const I = actor(); +const I = actor() -Given('ich habe ein Produkt mit einem Preis von {int}$ in meinem Warenkorb', (price) => { - I.addItem(parseInt(price, 10)); -}); +Given('ich habe ein Produkt mit einem Preis von {int}$ in meinem Warenkorb', price => { + I.addItem(parseInt(price, 10)) +}) -Given('der Rabatt für Bestellungen über $\{int} beträgt {int} %', (maxPrice, discount) => { // eslint-disable-line - I.haveDiscountForPrice(maxPrice, discount); -}); +Given('der Rabatt für Bestellungen über $\{int} beträgt {int} %', (maxPrice, discount) => { + I.haveDiscountForPrice(maxPrice, discount) +}) When('ich zur Kasse gehe', () => { - I.checkout(); -}); + I.checkout() +}) -Then('sollte ich den Gesamtpreis von "{float}" $ sehen', (price) => { - I.seeSum(price); -}); +Then('sollte ich den Gesamtpreis von "{float}" $ sehen', price => { + I.seeSum(price) +}) diff --git a/test/data/sandbox/features/step_definitions/my_steps.js b/test/data/sandbox/features/step_definitions/my_steps.js index 1dd5c52de..5c9cc2973 100644 --- a/test/data/sandbox/features/step_definitions/my_steps.js +++ b/test/data/sandbox/features/step_definitions/my_steps.js @@ -1,61 +1,63 @@ -const I = actor(); +const I = actor() -Given(/I have product with \$(\d+) price/, (price) => { - I.addItem(parseInt(price, 10)); -}); +Given(/I have product with \$(\d+) price/, price => { + I.addItem(parseInt(price, 10)) +}) When('I go to checkout process', () => { - I.checkout(); - I.checkout(); -}); + I.checkout() + I.checkout() +}) -Then('I should see that total number of products is {int}', (num) => { - I.seeNum(num); -}); -Then('my order amount is ${int}', (sum) => { // eslint-disable-line - I.seeSum(sum); -}); +Then('I should see that total number of products is {int}', num => { + I.seeNum(num) +}) +Then('my order amount is ${int}', sum => { + I.seeSum(sum) +}) -Given('I have product with price {int}$ in my cart', (price) => { - I.addItem(parseInt(price, 10)); -}); +Given('I have product with price {int}$ in my cart', price => { + I.addItem(parseInt(price, 10)) +}) -Given('discount for orders greater than ${int} is {int} %', (maxPrice, discount) => { // eslint-disable-line - I.haveDiscountForPrice(maxPrice, discount); -}); +Given('discount for orders greater than ${int} is {int} %', (maxPrice, discount) => { + I.haveDiscountForPrice(maxPrice, discount) +}) When('I go to checkout', () => { - I.checkout(); -}); + I.checkout() +}) -Then('I should see overall price is "{float}" $', (price) => { - I.seeSum(price); -}); +Then('I should see overall price is "{float}" $', price => { + I.seeSum(price) +}) Given('I login', () => { - I.login('user', secret('password')); -}); + I.login('user', secret('password')) +}) -Given(/^I have this product in my cart$/, (table) => { - let str = ''; +Given(/^I have this product in my cart$/, table => { + let str = '' for (const id in table.rows) { - const cells = table.rows[id].cells; - str += cells.map(c => c.value).map(c => c.slice(0, 15).padEnd(15)).join(' | '); - str += '\n'; + const cells = table.rows[id].cells + str += cells + .map(c => c.value) + .map(c => c.slice(0, 15).padEnd(15)) + .join(' | ') + str += '\n' } - console.log(str); -}); + console.log(str) +}) -Then(/^I should see total price is "([^"]*)" \$$/, () => { -}); +Then(/^I should see total price is "([^"]*)" \$$/, () => {}) -Before((test) => { - console.log(`-- before ${test.title} --`); -}); +Before(test => { + console.log(`-- before ${test.title} --`) +}) -After((test) => { - console.log(`-- after ${test.title} --`); -}); +After(test => { + console.log(`-- after ${test.title} --`) +}) -Fail((test) => { - console.log(`-- failed ${test.title} --`); -}); +Fail(test => { + console.log(`-- failed ${test.title} --`) +}) diff --git a/test/data/sandbox/i18n/features/step_definitions/my_steps.de.js b/test/data/sandbox/i18n/features/step_definitions/my_steps.de.js index 0fdc12f1c..98d1e549f 100644 --- a/test/data/sandbox/i18n/features/step_definitions/my_steps.de.js +++ b/test/data/sandbox/i18n/features/step_definitions/my_steps.de.js @@ -1,17 +1,17 @@ -const I = actor(); +const I = actor() -Given('ich habe ein Produkt mit einem Preis von {int}$ in meinem Warenkorb', (price) => { - I.addItem(parseInt(price, 10)); -}); +Given('ich habe ein Produkt mit einem Preis von {int}$ in meinem Warenkorb', price => { + I.addItem(parseInt(price, 10)) +}) -Given('der Rabatt für Bestellungen über $\{int} beträgt {int} %', (maxPrice, discount) => { // eslint-disable-line - I.haveDiscountForPrice(maxPrice, discount); -}); +Given('der Rabatt für Bestellungen über $\{int} beträgt {int} %', (maxPrice, discount) => { + I.haveDiscountForPrice(maxPrice, discount) +}) When('ich zur Kasse gehe', () => { - I.checkout(); -}); + I.checkout() +}) -Then('sollte ich den Gesamtpreis von "{float}" $ sehen', (price) => { - I.seeSum(price); -}); +Then('sollte ich den Gesamtpreis von "{float}" $ sehen', price => { + I.seeSum(price) +}) diff --git a/test/runner/bdd_test.js b/test/runner/bdd_test.js index a25932ad7..e959a31b5 100644 --- a/test/runner/bdd_test.js +++ b/test/runner/bdd_test.js @@ -14,7 +14,6 @@ describe('BDD Gherkin', () => { it('should run feature files', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Checkout process"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Checkout process') // feature stdout.should.include('-- before checkout --') stdout.should.include('-- after checkout --') @@ -32,7 +31,6 @@ describe('BDD Gherkin', () => { it('should print substeps in debug mode', done => { exec(config_run_config('codecept.bdd.js') + ' --debug --grep "Checkout process"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Checkout process') // feature // stdout.should.include('In order to buy products'); // test name stdout.should.include('Given I have product with $600 price') @@ -50,7 +48,6 @@ describe('BDD Gherkin', () => { it('should print events in nodejs debug mode', done => { exec(`DEBUG=codeceptjs:* ${config_run_config('codecept.bdd.js')} --grep "Checkout products" --debug`, (err, stdout, stderr) => { - //eslint-disable-line stderr.should.include('Emitted | step.start (I add product "Harry Potter", 5)') stdout.should.include('name | category | price') stdout.should.include('Harry Potter | Books | 5') @@ -63,7 +60,6 @@ describe('BDD Gherkin', () => { it('should obfuscate secret substeps in debug mode', done => { exec(config_run_config('codecept.bdd.js') + ' --debug --grep "Secrets"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Given I login') // feature stdout.should.not.include('password') assert(!err) @@ -73,7 +69,6 @@ describe('BDD Gherkin', () => { it('should run feature with examples files', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Checkout examples"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include(' order discount {"price":"10","total":"10.0"}') stdout.should.include(' Given I have product with price 10$ in my cart') @@ -95,7 +90,6 @@ describe('BDD Gherkin', () => { it('should run feature with table and examples files', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Include Examples in dataTtable placeholder"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('name | Nuclear Bomb ') stdout.should.include('price | 20 ') stdout.should.include('name | iPhone 5 ') @@ -107,7 +101,6 @@ describe('BDD Gherkin', () => { it('should show data from examples in test title', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Include Examples in dataTtable placeholder"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('order a product with discount - iPhone 5 - 10 @IncludeExamplesIndataTtable') stdout.should.include('name | Nuclear Bomb ') stdout.should.include('price | 20 ') @@ -120,7 +113,6 @@ describe('BDD Gherkin', () => { it('should run feature with tables', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Checkout products"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Given I have products in my cart') stdout.should.include('name') stdout.should.include('Harry Potter') @@ -134,7 +126,6 @@ describe('BDD Gherkin', () => { it('should run feature with tables contain long text', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Checkout products"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Given I have products in my cart') stdout.should.include('name') stdout.should.include('Harry Potter and the deathly hallows') @@ -145,7 +136,6 @@ describe('BDD Gherkin', () => { it('should run feature with long strings', done => { exec(config_run_config('codecept.bdd.js') + ' --steps --grep "Checkout string"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Given I have product described as') stdout.should.include('The goal of the product description is to provide the customer with enough information to compel them to want to buy the product immediately.') stdout.should.include('Then my order amount is $582') @@ -156,7 +146,6 @@ describe('BDD Gherkin', () => { it('should run feature by file name', done => { exec(config_run_config('codecept.bdd.js') + ' --steps features/tables.feature', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Checkout product') stdout.should.include('checkout 3 products') stdout.should.not.include('Checkout string') @@ -170,7 +159,6 @@ describe('BDD Gherkin', () => { it('should run feature by scenario name', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "checkout 3 products" --steps', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Checkout product') stdout.should.include('checkout 3 products') stdout.should.not.include('Checkout string') @@ -184,7 +172,6 @@ describe('BDD Gherkin', () => { it('should run feature by tag name', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "@important" --steps', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('I have product with $600 price in my cart') stdout.should.not.include('Checkout string') stdout.should.not.include('describe product') @@ -197,7 +184,6 @@ describe('BDD Gherkin', () => { it('should run scenario by tag name', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "@very" --steps', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('I have product with $600 price in my cart') stdout.should.not.include('Checkout string') stdout.should.not.include('describe product') @@ -210,7 +196,6 @@ describe('BDD Gherkin', () => { it('should run scenario outline by tag', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "@user" --steps', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.not.include('0 passed') stdout.should.include('I have product with price 10$') assert(!err) @@ -220,7 +205,6 @@ describe('BDD Gherkin', () => { it('should run scenario and scenario outline by tags', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "@user|@very" --steps', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.not.include('0 passed') stdout.should.include('I have product with price 10$') stdout.should.include('I have product with $600 price in my cart') @@ -232,7 +216,6 @@ describe('BDD Gherkin', () => { it('should run scenario and scenario outline by tags', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "@user|@very" --steps', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.not.include('0 passed') stdout.should.include('I have product with price 10$') stdout.should.include('I have product with $600 price in my cart') @@ -244,7 +227,6 @@ describe('BDD Gherkin', () => { it('should run not get stuck on failing step', done => { exec(config_run_config('codecept.bdd.js') + ' --grep "@fail" --steps', (err, stdout, stderr) => { - //eslint-disable-line // stdout.should.include('Given I make a request (and it fails)'); // stdout.should.not.include('Then my test execution gets stuck'); stdout.should.include('1 failed') @@ -256,7 +238,6 @@ describe('BDD Gherkin', () => { it('should show all available steps', done => { exec(`${runner} gherkin:steps --config ${codecept_dir}/codecept.bdd.js`, (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('Gherkin') stdout.should.include('/I have product with \\$(\\d+) price/') stdout.should.include('step_definitions/my_steps.js:3:1') @@ -270,7 +251,6 @@ describe('BDD Gherkin', () => { it('should generate snippets for missing steps', done => { exec(`${runner} gherkin:snippets --dry-run --config ${codecept_dir}/codecept.dummy.bdd.js`, (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include(`Given('I open a browser on a site', () => { // From "support/dummy.feature" {"line":4,"column":5} throw new Error('Not implemented yet'); @@ -342,7 +322,6 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { it('should not generate duplicated steps', done => { exec(`${runner} gherkin:snippets --dry-run --config ${codecept_dir}/codecept.duplicate.bdd.js`, (err, stdout, stderr) => { - //eslint-disable-line assert.equal(stdout.match(/I open a browser on a site/g).length, 1) assert(!err) done() @@ -358,7 +337,6 @@ When(/^I define a step with a \\( paren and a "(.*?)" string$/, () => { }) it('should run feature files in DE', done => { exec(config_run_config('codecept.bdd.de.js') + ' --steps --grep "@i18n"', (err, stdout, stderr) => { - //eslint-disable-line stdout.should.include('On Angenommen: ich habe ein produkt mit einem preis von 10$ in meinem warenkorb') stdout.should.include('On Und: der rabatt für bestellungen über $20 beträgt 10 %') stdout.should.include('On Wenn: ich zur kasse gehe') diff --git a/test/runner/dry_run_test.js b/test/runner/dry_run_test.js index a8fe63ff5..c7746a42c 100644 --- a/test/runner/dry_run_test.js +++ b/test/runner/dry_run_test.js @@ -86,7 +86,6 @@ describe('dry-run command', () => { it('should run feature files', done => { exec(codecept_run_config('codecept.bdd.js') + ' --steps --grep "Checkout process"', (err, stdout) => { - //eslint-disable-line expect(stdout).toContain('Checkout process') // feature expect(stdout).toContain('-- before checkout --') expect(stdout).toContain('-- after checkout --') @@ -105,7 +104,6 @@ describe('dry-run command', () => { it('should run feature files with regex grep', done => { exec(codecept_run_config('codecept.bdd.js') + ' --steps --grep "(?=.*Checkout process)"', (err, stdout) => { - //eslint-disable-line expect(stdout).toContain('Checkout process') // feature expect(stdout).toContain('-- before checkout --') expect(stdout).toContain('-- after checkout --') @@ -124,7 +122,6 @@ describe('dry-run command', () => { it('should print substeps in debug mode', done => { exec(codecept_run_config('codecept.bdd.js') + ' --debug --grep "Checkout process @important"', (err, stdout) => { - //eslint-disable-line expect(stdout).toContain('Checkout process') // feature // expect(stdout).toContain('In order to buy products'); // test name expect(stdout).toContain('Given I have product with $600 price') diff --git a/test/unit/bdd_test.js b/test/unit/bdd_test.js index 537cc9b9b..4ece96931 100644 --- a/test/unit/bdd_test.js +++ b/test/unit/bdd_test.js @@ -263,8 +263,8 @@ describe('BDD', () => { let fn Given('I am a {word}', params => params[0]) When('I have {int} wings and {int} eyes', params => params[0] + params[1]) - Given('I have ${int} in my pocket', params => params[0]) // eslint-disable-line no-template-curly-in-string - Given('I have also ${float} in my pocket', params => params[0]) // eslint-disable-line no-template-curly-in-string + Given('I have ${int} in my pocket', params => params[0]) + Given('I have also ${float} in my pocket', params => params[0]) fn = matchStep('I am a bird') expect('bird').is.equal(fn(fn.params)) fn = matchStep('I have 2 wings and 2 eyes')