Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,18 @@
"prefer-rest-params": 0,
"no-useless-escape": 0,
"no-restricted-syntax": 0,
"one-var": 0,
"no-unused-expressions": 0,
"eqeqeq": 0,
"guard-for-in": 0,
"no-multi-assign": 0,
"require-yield": 0,
"prefer-spread": 0,
"radix": 0,
"import/no-dynamic-require": 0,
"prefer-const": 0,
"no-empty": 0,
"no-tabs": 0,
"no-continue": 0,
"no-mixed-operators": 0,
"default-case": 0,
"import/no-extraneous-dependencies": 0,
"no-bitwise": 0,
"no-array-constructor": 0,
"no-cond-assign": 0,
"no-var": 0,
"no-buffer-constructor": 0,
"no-eval": 0,
"array-callback-return": 0,
"no-loop-func": 0,
"quotes": 0,
"import/no-unresolved": 0,
"no-redeclare": 0,
"function-paren-newline": 0,
"no-useless-return": 0
"function-paren-newline": 0
}
}
2 changes: 1 addition & 1 deletion examples/pages/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let I;
module.exports = {

_init() {
I = require('codeceptjs/actor')();
I = actor();
},

// insert your locators and methods here
Expand Down
2 changes: 1 addition & 1 deletion lib/codecept.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Codecept {
constructor(config, opts) {
this.config = Config.create(config);
this.opts = opts;
this.testFiles = new Array();
this.testFiles = [];
}

/**
Expand Down
6 changes: 2 additions & 4 deletions lib/command/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,9 @@ module.exports = function (initPath) {
print('Configure helpers...');
inquirer.prompt(helperConfigs, (helperResult) => {
Object.keys(helperResult).forEach((key) => {
let helperName,
configName;
const parts = key.split('_');
helperName = parts[0];
configName = parts[1];
const helperName = parts[0];
const configName = parts[1];
if (!configName) return;
config.helpers[helperName][configName] = helperResult[key];
});
Expand Down
4 changes: 2 additions & 2 deletions lib/command/run-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const output = require('../output');
const path = require('path');

const runner = path.join(__dirname, '/../../bin/codecept');
let config,
childOpts = {};
let config;
const childOpts = {};
const copyOptions = ['steps', 'reporter', 'verbose', 'config', 'reporter-options', 'grep', 'fgrep', 'debug'];

// codeceptjs run:multiple smoke:chrome regression:firefox - will launch smoke suite in chrome and regression in firefox
Expand Down
4 changes: 2 additions & 2 deletions lib/command/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = function (test, options) {
// registering options globally to use in config
process.profile = options.profile;
const configFile = options.config;
let codecept,
outputDir;
let codecept;
let outputDir;

const testRoot = getTestRoot(configFile);
let config = getConfig(configFile);
Expand Down
4 changes: 2 additions & 2 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ module.exports = Config;

function loadConfigFile(configFile) {
// .conf.js config file
if (path.extname(configFile) == '.js') {
if (path.extname(configFile) === '.js') {
return Config.create(require(configFile).config);
}

// json config provided
if (path.extname(configFile) == '.json') {
if (path.extname(configFile) === '.json') {
return Config.create(JSON.parse(fs.readFileSync(configFile, 'utf8')));
}
throw new Error(`Config file ${configFile} can't be loaded`);
Expand Down
2 changes: 1 addition & 1 deletion lib/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function createSupportObjects(config) {
if (!objects.I) {
objects.I = require('./actor')();

if (container.translation.I != 'I') {
if (container.translation.I !== 'I') {
objects[container.translation.I] = objects.I;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/data/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class DataTable {
constructor(array) {
this.array = array;
this.rows = new Array();
this.rows = [];
}

add(array) {
Expand Down
13 changes: 6 additions & 7 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Appium extends WebdriverIO {
* I.seeAppIsInstalled("com.example.android.apis");
* ```
*
* @param bundleId String ID of bundled app
* @param bundleId String ID of bundled app
*
* Appium: support only Android
*/
Expand All @@ -349,7 +349,7 @@ class Appium extends WebdriverIO {
* I.seeAppIsNotInstalled("com.example.android.apis");
* ```
*
* @param bundleId String ID of bundled app
* @param bundleId String ID of bundled app
*
* Appium: support only Android
*/
Expand Down Expand Up @@ -379,7 +379,7 @@ class Appium extends WebdriverIO {
* ```js
* I.removeApp('com.example.android.apis');
* ```
* @param bundleId String ID of bundled app
* @param bundleId String ID of bundled app
*
* Appium: support only Android
*/
Expand Down Expand Up @@ -678,7 +678,7 @@ class Appium extends WebdriverIO {
* I.hideDeviceKeyboard('pressKey', 'Done');
* ```
*
* @param strategy desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
* @param strategy desired strategy to close keyboard (‘tapOutside’ or ‘pressKey’)
*
* Appium: support Android and iOS
*/
Expand All @@ -696,7 +696,7 @@ class Appium extends WebdriverIO {
* I.sendDeviceKeyEvent(3);
* ```
*
* @param keyValue Device specific key value
* @param keyValue Device specific key value
*
* Appium: support only Android
*/
Expand Down Expand Up @@ -1255,7 +1255,6 @@ function parseLocator(locator) {

// in the end of a file
function onlyForApps(expectedPlatform) {
let callerName;
const stack = new Error().stack || '';
const re = /Appium.(\w+)/g;
const caller = stack.split('\n')[2].trim();
Expand All @@ -1265,7 +1264,7 @@ function onlyForApps(expectedPlatform) {
throw new Error(`Invalid caller ${caller}`);
}

callerName = m[1] || m[2];
const callerName = m[1] || m[2];
if (!expectedPlatform) {
if (!this.platform) {
throw new Error(`${callerName} method can be used only with apps`);
Expand Down
4 changes: 2 additions & 2 deletions lib/helper/Mochawesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Mochawesome extends Helper {
if (this.options.disableScreenshots) return;
let fileName;
// Get proper name if we are fail on hook
if (test.ctx.test.type == 'hook') {
if (test.ctx.test.type === 'hook') {
currentTest = { test: test.ctx.test };
// ignore retries if we are in hook
test._retries = -1;
Expand All @@ -57,7 +57,7 @@ class Mochawesome extends Helper {
const uuid = test.uuid || test.ctx.test.uuid;
fileName = `${fileName.substring(0, 10)}_${uuid}`;
}
if (test._retries < 1 || test._retries == test.retryNum) {
if (test._retries < 1 || test._retries === test.retryNum) {
fileName = `${fileName}.failed.png`;
return addMochawesomeContext(currentTest, fileName);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/helper/Nightmare.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ class Nightmare extends Helper {
const typeFn = () => child.call('type', text, done);

this.evaluate_now((el, clean) => {
var el = window.codeceptjs.fetchElement(el);
if (clean) el.value = '';
el.focus();
const element = window.codeceptjs.fetchElement(el);
if (clean) element.value = '';
element.focus();
}, () => {
if (clean) return typeFn();
child.call('pressKey', 'End', typeFn); // type End before
Expand Down Expand Up @@ -224,7 +224,7 @@ class Nightmare extends Helper {

if (this.options.windowSize) {
const size = this.options.windowSize.split('x');
return this.browser.viewport(parseInt(size[0]), parseInt(size[1]));
return this.browser.viewport(parseInt(size[0], 10), parseInt(size[1], 10));
}
});
}
Expand Down Expand Up @@ -889,8 +889,8 @@ class Nightmare extends Helper {
module.exports = Nightmare;

function proceedSee(assertType, text, context) {
let description,
locator;
let description;
let locator;
if (!context) {
if (this.context === this.options.rootElement) {
locator = guessLocator(this.context) || { css: this.context };
Expand Down
4 changes: 2 additions & 2 deletions lib/helper/Protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ class Protractor extends SeleniumWebdriver {
global.by = global.By = new By();
global.ExpectedConditions = EC = this.browser.ExpectedConditions;
const promisesList = [];
if (this.options.windowSize == 'maximize') {
if (this.options.windowSize === 'maximize') {
promisesList.push(this.resizeWindow(this.options.windowSize));
}
if (this.options.windowSize) {
const size = this.options.windowSize.split('x');
promisesList.push(this.resizeWindow(parseInt(size[0]), parseInt(size[1])));
promisesList.push(this.resizeWindow(parseInt(size[0], 10), parseInt(size[1], 10)));
}

return Promise.all(promisesList).then(() => this.isRunning = true);
Expand Down
25 changes: 13 additions & 12 deletions lib/helper/SeleniumWebdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SeleniumWebdriver extends Helper {
_startBrowser() {
this.browser = this.browserBuilder.build();
const promisesList = [];
if (this.options.windowSize == 'maximize') {
if (this.options.windowSize === 'maximize') {
promisesList.push(this.resizeWindow(this.options.windowSize));
} else if (this.options.windowSize && this.options.windowSize.indexOf('x') > 0) {
const size = this.options.windowSize.split('x');
Expand Down Expand Up @@ -189,10 +189,10 @@ class SeleniumWebdriver extends Helper {

_failed(test) {
const promisesList = [];
if (Object.keys(withinStore).length != 0) promisesList.push(this._withinEnd());
if (Object.keys(withinStore).length !== 0) promisesList.push(this._withinEnd());
if (!this.options.disableScreenshots) {
let fileName = clearString(test.title);
if (test.ctx && test.ctx.test && test.ctx.test.type == 'hook') fileName = clearString(`${test.title}_${test.ctx.test.title}`);
if (test.ctx && test.ctx.test && test.ctx.test.type === 'hook') fileName = clearString(`${test.title}_${test.ctx.test.title}`);
if (this.options.uniqueScreenshotNames) {
const uuid = test.uuid || test.ctx.test.uuid;
fileName = `${fileName.substring(0, 10)}_${uuid}.failed.png`;
Expand All @@ -204,7 +204,7 @@ class SeleniumWebdriver extends Helper {
return Promise.all(promisesList).catch((err) => {
if (err &&
err.type &&
err.type == 'RuntimeError' &&
err.type === 'RuntimeError' &&
err.message &&
(err.message.indexOf('was terminated due to') > -1 || err.message.indexOf('no such window: target window already closed') > -1)
) {
Expand Down Expand Up @@ -363,7 +363,8 @@ class SeleniumWebdriver extends Helper {
*/
pressKey(key) {
let modifier;
if (Array.isArray(key) && ~['Control', 'Command', 'Shift', 'Alt'].indexOf(key[0])) {
const mofidiers = ['Control', 'Command', 'Shift', 'Alt'];
if (Array.isArray(key) && mofidiers.includes(key[0])) {
modifier = this.webdriver.Key[key[0].toUpperCase()];
key = key[1];
}
Expand Down Expand Up @@ -615,7 +616,7 @@ class SeleniumWebdriver extends Helper {
const writeFile = (png, outputFile) => {
const fs = require('fs');
const stream = fs.createWriteStream(outputFile);
stream.write(new Buffer(png, 'base64'));
stream.write(Buffer.from(png, 'base64'));
stream.end();
return new Promise((resolve => stream.on('finish', resolve)));
};
Expand Down Expand Up @@ -695,8 +696,8 @@ class SeleniumWebdriver extends Helper {
resizeWindow(width, height) {
const client = this.browser;
if (width === 'maximize') {
return client.executeScript('return [screen.width, screen.height]').then(res => client.manage().window().setSize(parseInt(res[0]), parseInt(res[1])));
} return client.manage().window().setSize(parseInt(width), parseInt(height));
return client.executeScript('return [screen.width, screen.height]').then(res => client.manage().window().setSize(parseInt(res[0], 10), parseInt(res[1], 10)));
} return client.manage().window().setSize(parseInt(width, 10), parseInt(height, 10));
}

/**
Expand Down Expand Up @@ -844,8 +845,8 @@ function* findFields(client, locator) {
}

function proceedSee(assertType, text, context) {
let description,
locator;
let description;
let locator;
if (!context) {
if (this.context === this.options.rootElement) {
locator = guessLocator(this.context) || global.by.css(this.context);
Expand All @@ -859,7 +860,7 @@ function proceedSee(assertType, text, context) {
locator = guessLocator(context) || global.by.css(context);
description = `element ${context}`;
}
const enableSmartWait = !!this.context && assertType == 'assert';
const enableSmartWait = !!this.context && assertType === 'assert';
return this._smartWait(() => this.browser.findElements(locator), enableSmartWait).then(co.wrap(function* (els) {
const promises = [];
let source = '';
Expand All @@ -877,7 +878,7 @@ function* proceedSeeInField(assertType, field, value) {
const el = els[0];
const tag = yield el.getTagName();
const fieldVal = yield el.getAttribute('value');
if (tag == 'select') {
if (tag === 'select') {
// locate option by values and check them
const text = yield el.findElement(global.by.xpath(`./option[@value=${xpathLocator.literal(fieldVal)}]`)).getText();
return equals(`select option by ${field}`)[assertType](value, text);
Expand Down
Loading