diff --git a/api/index.js b/api/index.js index 2ca0a30a00..e2a0b033a0 100644 --- a/api/index.js +++ b/api/index.js @@ -16,7 +16,7 @@ const exportedCommands = [ const basePath = '../dist/api'; const Commands = {}; const props = exportedCommands.reduce((prev, fileName) => { - const commandName = fileName.substring(fileName.lastIndexOf('/')+1).replace('.js', ''); + const commandName = fileName.substring(fileName.lastIndexOf('/') + 1).replace('.js', ''); prev[commandName] = { configurable: true, get: function() { @@ -29,4 +29,4 @@ const props = exportedCommands.reduce((prev, fileName) => { Object.defineProperties(Commands, props); -module.exports = Commands; \ No newline at end of file +module.exports = Commands; diff --git a/examples/cucumber-js/features/step_definitions/nightwatch.js b/examples/cucumber-js/features/step_definitions/nightwatch.js index cbfffe3872..789cf23ad7 100644 --- a/examples/cucumber-js/features/step_definitions/nightwatch.js +++ b/examples/cucumber-js/features/step_definitions/nightwatch.js @@ -30,4 +30,4 @@ Then(/^the title is "([^"]*)"$/, function(title) { Then(/^Body contains "([^"]*)"$/, function(contains) { return browser.assert.textContains('.search-results', contains); -}); \ No newline at end of file +}); diff --git a/examples/custom-commands/strictClick.js b/examples/custom-commands/strictClick.js index 99afe91ffb..e5686811fd 100644 --- a/examples/custom-commands/strictClick.js +++ b/examples/custom-commands/strictClick.js @@ -3,4 +3,4 @@ module.exports = { return this.waitForElementVisible(selector) .click(selector); } -}; \ No newline at end of file +}; diff --git a/examples/pages/google/search.js b/examples/pages/google/search.js index 04df86b323..430d8dc1f0 100644 --- a/examples/pages/google/search.js +++ b/examples/pages/google/search.js @@ -2,7 +2,7 @@ const searchCommands = { submit() { this.waitForElementVisible('@submitButton', 1000) .click('@submitButton'); - + this.pause(1000); return this; // Return page object for chaining diff --git a/examples/pages/google/searchResults.js b/examples/pages/google/searchResults.js index 72684c1533..35061c08cf 100644 --- a/examples/pages/google/searchResults.js +++ b/examples/pages/google/searchResults.js @@ -6,7 +6,7 @@ const menuCommands = { var self = this; return this.getAttribute(product, 'class', function (result) { - let isSelected = result.value.indexOf('hdtb-msel') > -1; + const isSelected = result.value.indexOf('hdtb-msel') > -1; callback.call(self, isSelected); }); } @@ -44,4 +44,4 @@ module.exports = { } } } -}; \ No newline at end of file +}; diff --git a/examples/tests/chromeCDP_example.js b/examples/tests/chromeCDP_example.js index ea08a33063..4f6709faa2 100644 --- a/examples/tests/chromeCDP_example.js +++ b/examples/tests/chromeCDP_example.js @@ -1,7 +1,7 @@ describe('Chrome DevTools Example', function() { this.disabled = this.argv.env !== 'chrome'; - + it ('using CDP DOM Snapshot', async function(browser) { await browser.navigateTo('https://nightwatchjs.org'); @@ -11,4 +11,4 @@ describe('Chrome DevTools Example', function() { browser.assert.deepStrictEqual(Object.keys(dom), ['documents', 'strings']); }); -}); \ No newline at end of file +}); diff --git a/examples/tests/duckDuckGo.js b/examples/tests/duckDuckGo.js index 24863a7167..4c5c1c38c2 100644 --- a/examples/tests/duckDuckGo.js +++ b/examples/tests/duckDuckGo.js @@ -11,5 +11,5 @@ describe('duckduckgo example', function() { .assert.visible('button[type=submit]') .click('button[type=submit]') .assert.textContains('.react-results--main', 'Nightwatch.js'); - }); + }); }); diff --git a/examples/tests/element/elementapi-tests.js b/examples/tests/element/elementapi-tests.js index 99b37861b3..eba4b3652b 100644 --- a/examples/tests/element/elementapi-tests.js +++ b/examples/tests/element/elementapi-tests.js @@ -79,4 +79,4 @@ describe('queries tests', function() { }); -}); \ No newline at end of file +}); diff --git a/examples/tests/sample-with-relative-locators.js b/examples/tests/sample-with-relative-locators.js index b8f9d4f301..65d8f82a4c 100644 --- a/examples/tests/sample-with-relative-locators.js +++ b/examples/tests/sample-with-relative-locators.js @@ -22,4 +22,4 @@ describe('sample with relative locators', function () { }); after(browser => browser.end()); -}); \ No newline at end of file +}); diff --git a/examples/tests/selectElement.js b/examples/tests/selectElement.js index 0d7a0176ad..c026cd5465 100644 --- a/examples/tests/selectElement.js +++ b/examples/tests/selectElement.js @@ -13,4 +13,4 @@ module.exports = { }) .assert.selected(await selectElement.findElement('option[value=four]'), 'Forth option is selected'); } -}; \ No newline at end of file +}; diff --git a/examples/tests/shadowRootExample.js b/examples/tests/shadowRootExample.js index abe7d6dfce..462c875c34 100644 --- a/examples/tests/shadowRootExample.js +++ b/examples/tests/shadowRootExample.js @@ -50,4 +50,4 @@ describe('Shadow Root example test', function() { // await expect.element(firstElement).to.be.an('img'); }); -}); \ No newline at end of file +}); diff --git a/examples/unittests/testUtils.js b/examples/unittests/testUtils.js index bff4a13f2f..c091100170 100644 --- a/examples/unittests/testUtils.js +++ b/examples/unittests/testUtils.js @@ -19,4 +19,4 @@ module.exports = { assert.strictEqual(Utils.getTestSuiteName('test.case.one'), 'Test Case One'); assert.strictEqual(Utils.getTestSuiteName('testCaseOne'), 'Test Case One'); } -}; \ No newline at end of file +}; diff --git a/examples/unittests/testUtilsWithChai.js b/examples/unittests/testUtilsWithChai.js index 4e6adc8108..6f8d701800 100644 --- a/examples/unittests/testUtilsWithChai.js +++ b/examples/unittests/testUtilsWithChai.js @@ -16,4 +16,4 @@ module.exports = { var resultMs = Utils.formatElapsedTime(999); expect(resultMs).to.equal('999ms'); } -}; \ No newline at end of file +}; diff --git a/lib/api/_loaders/_base-loader.js b/lib/api/_loaders/_base-loader.js index 0942aba134..14c2a4c7d1 100644 --- a/lib/api/_loaders/_base-loader.js +++ b/lib/api/_loaders/_base-loader.js @@ -399,20 +399,20 @@ class BaseLoader extends EventEmitter { const options = this.getCommandOptions(); - if (args && args.length > 0 && Utils.isFunction(args[args.length-1])) { + if (args && args.length > 0 && Utils.isFunction(args[args.length - 1])) { const callback = args.pop(); - + const userCallbackWrapper = (function(context) { - + const proxyFn = new Proxy(callback, { apply: function(target, thisArg, argumentsList) { context.addedInsideCallback = true; - + return target.apply(thisArg, argumentsList); } }); proxyFn.originalTarget = callback; - + return proxyFn; })(this); diff --git a/lib/api/_loaders/command.js b/lib/api/_loaders/command.js index 2843a9cc2f..3afd576d5b 100644 --- a/lib/api/_loaders/command.js +++ b/lib/api/_loaders/command.js @@ -42,7 +42,7 @@ class CommandLoader extends BaseCommandLoader { return function(...args) { let callback; let method; - const isLastArgFunction = isFunction(args[args.length-1]); + const isLastArgFunction = isFunction(args[args.length - 1]); if (isLastArgFunction) { callback = args.pop(); @@ -74,8 +74,8 @@ class CommandLoader extends BaseCommandLoader { reportProtocolErrors(result) { if (opts.isUserDefined) { return true; - } - + } + return super.reportProtocolErrors(result); } @@ -85,11 +85,11 @@ class CommandLoader extends BaseCommandLoader { get reuseBrowser() { return nightwatchInstance.argv['reuse-browser'] || (nightwatchInstance.settings.globals && nightwatchInstance.settings.globals.reuseBrowserSession); - } - + } + get isES6AsyncCommand() { return isES6AsyncFn( - CommandLoader.isDeprecatedCommandStyle(CommandModule) ? CommandModule.command: this.command + CommandLoader.isDeprecatedCommandStyle(CommandModule) ? CommandModule.command : this.command ); } @@ -210,7 +210,7 @@ class CommandLoader extends BaseCommandLoader { if (result.stack) { err.stack = result.stack; } - + if (result.error instanceof Error) { result.error.registered = true; } else { diff --git a/lib/api/_loaders/element-global.js b/lib/api/_loaders/element-global.js index ebed36155d..30f7a53024 100644 --- a/lib/api/_loaders/element-global.js +++ b/lib/api/_loaders/element-global.js @@ -161,7 +161,7 @@ class ElementGlobal { value = { value: locator, using: this.client.locateStrategy - }; + }; } else { value = locator; } @@ -267,7 +267,7 @@ class ElementGlobal { }); } - const lastArg = args[args.length-1]; + const lastArg = args[args.length - 1]; if (isFunction(lastArg)) { if (error) { return lastArg.call(this.api, { diff --git a/lib/api/_loaders/expect.js b/lib/api/_loaders/expect.js index 24ee01f385..a186f083ad 100644 --- a/lib/api/_loaders/expect.js +++ b/lib/api/_loaders/expect.js @@ -115,7 +115,7 @@ class ExpectLoader extends BaseCommandLoader { deferred.reject(err); }); } - + return expectCommand.instance; }.bind(this)); } diff --git a/lib/api/_loaders/static.js b/lib/api/_loaders/static.js index 913a9dd14d..dc75f485ba 100644 --- a/lib/api/_loaders/static.js +++ b/lib/api/_loaders/static.js @@ -182,7 +182,7 @@ module.exports = class StaticAssert { Object.assign(node.deferred.promise, apiToReturn || this.api); - //prevent unhandled rejection + //prevent unhandled rejection node.deferred.promise.catch(err => { return StaticAssert.lastDeferred.reject(err); }); diff --git a/lib/api/assertions/_assertionInstance.js b/lib/api/assertions/_assertionInstance.js index 273671ee0c..7bca65cbab 100644 --- a/lib/api/assertions/_assertionInstance.js +++ b/lib/api/assertions/_assertionInstance.js @@ -21,7 +21,7 @@ class AssertionInstance { } static init({nightwatchInstance, args, fileName, options}) { - if (Utils.isFunction(args[args.length-1])) { + if (Utils.isFunction(args[args.length - 1])) { this.__doneCallback = args.pop(); } else { this.__doneCallback = function(result) { diff --git a/lib/api/assertions/domPropertyMatches.js b/lib/api/assertions/domPropertyMatches.js index be80463240..ff03f08e77 100644 --- a/lib/api/assertions/domPropertyMatches.js +++ b/lib/api/assertions/domPropertyMatches.js @@ -1,12 +1,12 @@ /** * Check if specified DOM property value of a given element matches a regex. For all the available DOM element properties, consult the [Element doc at MDN](https://developer.mozilla.org/en-US/docs/Web/API/element). - * - * + * + * * @example * this.demoTest = function (browser) { * browser.assert.domPropertyMatches('#main', 'tagName', /^frame/); * } - * + * * @method assert.domPropertyMatches * @param {string|object} definition The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies [element properties](https://nightwatchjs.org/guide#element-properties). * @param {string} domProperty The DOM property name. @@ -41,10 +41,10 @@ exports.assertion = function (definition, domProperty, regexExpression, msg) { if (!Array.isArray(value)) { return regex.test(value); - } + } return false; - }; + }; this.value = function(result = {}) { return result.value || ''; diff --git a/lib/api/assertions/elementsCount.js b/lib/api/assertions/elementsCount.js index 68d0e244a7..c8b5285817 100644 --- a/lib/api/assertions/elementsCount.js +++ b/lib/api/assertions/elementsCount.js @@ -50,7 +50,7 @@ exports.assertion = function (definition, count, msg) { this.command = async function(callback) { - + await this.api.findElements(definition, callback); }; }; diff --git a/lib/api/assertions/enabled.js b/lib/api/assertions/enabled.js index 686542abf5..9e42334314 100644 --- a/lib/api/assertions/enabled.js +++ b/lib/api/assertions/enabled.js @@ -21,7 +21,7 @@ exports.assertion = function(definition, msg) { this.formatMessage = function() { const message = msg || `Testing if element %s ${this.negate ? 'is not enabled' : 'is enabled'}`; - + return { message, args: [this.elementSelector] @@ -43,5 +43,5 @@ exports.assertion = function(definition, msg) { this.command = function(callback) { this.api.isEnabled(definition, callback); }; - + }; diff --git a/lib/api/assertions/hasAttribute.js b/lib/api/assertions/hasAttribute.js index c05de41cd0..8143b300d4 100644 --- a/lib/api/assertions/hasAttribute.js +++ b/lib/api/assertions/hasAttribute.js @@ -3,12 +3,12 @@ * Checks if the given element contains the specified DOM attribute. * * Equivalent of: https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute - * + * * @example * this.demoTest = function (browser) { * browser.assert.hasAttribute('#main', 'data-track'); * }; - * + * * @method assert.hasAttribute * @param {string|object} definition The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies [element properties](https://nightwatchjs.org/guide#element-properties). * @param {string} expectedAttribute The DOM attribute to look for. @@ -26,15 +26,15 @@ exports.assertion = function(definition, expectedAttribute, msg) { this.expected = function() { return this.negate ? `has not ${expectedAttribute}` : `has ${expectedAttribute}`; }; - + this.formatMessage = function() { if (!isString(expectedAttribute)) { throw new Error('Expected attribute must be a string'); } - let message = msg || `Testing if element %s ${this.negate ? 'doesn\'t have attribute %s' : 'has attribute %s'}`; - + const message = msg || `Testing if element %s ${this.negate ? 'doesn\'t have attribute %s' : 'has attribute %s'}`; + return { message, args: [this.elementSelector, `'${expectedAttribute}'`] @@ -47,7 +47,7 @@ exports.assertion = function(definition, expectedAttribute, msg) { if (!result || !result.value) { return false; } - + return true; }; diff --git a/lib/api/assertions/hasClass.js b/lib/api/assertions/hasClass.js index 077ff18ab6..fa115dd5b3 100644 --- a/lib/api/assertions/hasClass.js +++ b/lib/api/assertions/hasClass.js @@ -1,6 +1,6 @@ /** * Checks if the given element has the specified CSS class. - * + * * @example * this.demoTest = function (browser) { * browser.assert.hasClass('#main', 'container'); @@ -18,7 +18,7 @@ const classListRegexp = /\s/; const classNameRegexp = /\w/; const {containsMultiple, setElementSelectorProps} = require('../../utils'); - + exports.assertion = function(definition, expected, msg) { this.options = { elementSelector: true @@ -27,41 +27,40 @@ exports.assertion = function(definition, expected, msg) { this.expected = function() { return this.negate ? `has not ${expected}` : `has ${expected}`; }; - + this.formatMessage = function() { - let message = msg || `Testing if element %s ${this.negate ? 'doesn\'t have css class %s' : 'has css class %s'}`; - + const message = msg || `Testing if element %s ${this.negate ? 'doesn\'t have css class %s' : 'has css class %s'}`; + return { message, args: [this.elementSelector, `'${Array.isArray(expected) ? expected.join(' ') : expected}'`] }; }; - - + + this.evaluate = function() { if (!this.classList) { return false; } - + return containsMultiple(this.classList, expected, ' '); }; - + this.value = function(result) { if (!result || !result.value) { return ''; } - + this.classList = result.value .split(classListRegexp) .filter(item => classNameRegexp.test(item)); - + return result.value; }; - + this.command = function(callback) { this.api.getAttribute(setElementSelectorProps(definition, { suppressNotFoundErrors: true }), 'class', callback); }; }; - \ No newline at end of file diff --git a/lib/api/assertions/selected.js b/lib/api/assertions/selected.js index 296c01549d..90528945a4 100644 --- a/lib/api/assertions/selected.js +++ b/lib/api/assertions/selected.js @@ -44,4 +44,4 @@ exports.assertion = function(definition, msg) { this.api.isSelected(definition, callback); }; -}; \ No newline at end of file +}; diff --git a/lib/api/assertions/textEquals.js b/lib/api/assertions/textEquals.js index 17fe92fdc5..4d83a80eef 100644 --- a/lib/api/assertions/textEquals.js +++ b/lib/api/assertions/textEquals.js @@ -5,7 +5,7 @@ * this.demoTest = function (browser) { * browser.assert.textEquals('#main', 'The Night Watch'); * }; - * + * * @method assert.textEquals * @param {string|object} definition The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies [element properties](https://nightwatchjs.org/guide#element-properties). * @param {string} expected text to match text. @@ -19,20 +19,20 @@ exports.assertion = function(definition, expected, msg) { this.options = { elementSelector: true }; - + this.formatMessage = function() { const message = msg || `Testing if element's %s inner text ${this.negate ? 'doesn\'t equal %s' : 'equals %s'}`; - + return { message, args: [this.elementSelector, `'${expected}'`] }; }; - + this.expected = function() { return this.negate ? `doesn't equal '${expected}'` : `equals '${expected}'`; }; - + this.evaluate = function(value) { if (typeof value != 'string') { return false; @@ -67,4 +67,4 @@ exports.assertion = function(definition, expected, msg) { suppressNotFoundErrors: true }), callback); }; -}; \ No newline at end of file +}; diff --git a/lib/api/assertions/textMatches.js b/lib/api/assertions/textMatches.js index 9adb84e3f0..d09e14a790 100644 --- a/lib/api/assertions/textMatches.js +++ b/lib/api/assertions/textMatches.js @@ -5,7 +5,7 @@ * this.demoTest = function (browser) { * browser.assert.textMatches('#main', '^Nightwatch'); * }; - * + * * @method assert.textMatches * @param {string|object} definition The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies [element properties](https://nightwatchjs.org/guide#element-properties). * @param {string|RegExp} regexExpression Regex expression to match text. diff --git a/lib/api/assertions/titleEquals.js b/lib/api/assertions/titleEquals.js index 2897d6ed58..7ac6865b22 100644 --- a/lib/api/assertions/titleEquals.js +++ b/lib/api/assertions/titleEquals.js @@ -1,6 +1,6 @@ /** * Checks if the page title equals the given value. - * + * * @example * this.demoTest = function (client) { * browser.assert.titleEquals('https://www.google.com'); diff --git a/lib/api/assertions/titleMatches.js b/lib/api/assertions/titleMatches.js index 445f414993..35a89d8bd5 100644 --- a/lib/api/assertions/titleMatches.js +++ b/lib/api/assertions/titleMatches.js @@ -5,7 +5,7 @@ * this.demoTest = function (client) { * browser.assert.titleMatches('^Nightwatch'); * }; - * + * * @method assert.titleMatches * @param {string|RegExp} regexExpression Regex expression to match current title of a page * @param {string} [msg] Optional log message to display in the output. If missing, one is displayed by default. diff --git a/lib/api/assertions/urlMatches.js b/lib/api/assertions/urlMatches.js index 5b5d05a20a..a33910fc5c 100644 --- a/lib/api/assertions/urlMatches.js +++ b/lib/api/assertions/urlMatches.js @@ -5,7 +5,7 @@ * this.demoTest = function (client) { * browser.assert.urlMatches('^https'); * }; - * + * * @method assert.urlMatches * @param {string|RegExp} regexExpression Regex expression to match URL * @param {string} [msg] Optional log message to display in the output. If missing, one is displayed by default. diff --git a/lib/api/assertions/valueEquals.js b/lib/api/assertions/valueEquals.js index 011070c457..14a3d291e5 100644 --- a/lib/api/assertions/valueEquals.js +++ b/lib/api/assertions/valueEquals.js @@ -1,10 +1,10 @@ /** * Checks if the given form element's value equals the expected value. - * + * * The existing .assert.value() command. * - * + * * @example * this.demoTest = function (browser) { * browser.assert.valueEquals("form.login input[type=text]", "username"); diff --git a/lib/api/client-commands/alerts/setText.js b/lib/api/client-commands/alerts/setText.js index 5b2e06b792..4f817d8f8d 100644 --- a/lib/api/client-commands/alerts/setText.js +++ b/lib/api/client-commands/alerts/setText.js @@ -44,7 +44,7 @@ class SetAlertText extends ClientCommand { } this.alertText = value; - + return super.command(callback); } } diff --git a/lib/api/client-commands/axeInject.js b/lib/api/client-commands/axeInject.js index 4a72d758db..99332b6147 100644 --- a/lib/api/client-commands/axeInject.js +++ b/lib/api/client-commands/axeInject.js @@ -25,4 +25,4 @@ module.exports = class AxeInjectAbstract { static get allowOverride() { return true; } -}; \ No newline at end of file +}; diff --git a/lib/api/client-commands/debug.js b/lib/api/client-commands/debug.js index 76e1477b56..f2c313017a 100644 --- a/lib/api/client-commands/debug.js +++ b/lib/api/client-commands/debug.js @@ -7,7 +7,7 @@ const Debuggability = require('../../utils/debuggability.js'); * This command halts the test execution and provides users with a REPL interface where they can type * any of the available Nightwatch commands and the command will be executed in the running browser * in real-time. - * + * * This can be used to debug why a certain command in not working as expected, find the correct * locators for your assertions or just play around with the available Nightwatch commands. * @@ -16,10 +16,10 @@ const Debuggability = require('../../utils/debuggability.js'); * // command to get the correct result as output. * this.demoTest = async function (browser) { * browser.debug(); - * + * * // with no auto-complete * browser.debug({preview: false}); - * + * * // with a timeout of 6000 ms (time for which the interface * // would wait for a result). * browser.debug({timeout: 6000}) diff --git a/lib/api/client-commands/document/injectScript.js b/lib/api/client-commands/document/injectScript.js index 9954cf28ed..790dc88339 100644 --- a/lib/api/client-commands/document/injectScript.js +++ b/lib/api/client-commands/document/injectScript.js @@ -50,7 +50,7 @@ class InjectScript extends ClientCommand { this.scriptFn = 'var passedArgs = Array.prototype.slice.call(arguments,0); return (' + script.toString() + ').apply(window, passedArgs);'; - this.scriptArgs = args; + this.scriptArgs = args; return super.command(callback); } diff --git a/lib/api/client-commands/enablePerformanceMetrics.js b/lib/api/client-commands/enablePerformanceMetrics.js index 1494188522..3439346cb1 100644 --- a/lib/api/client-commands/enablePerformanceMetrics.js +++ b/lib/api/client-commands/enablePerformanceMetrics.js @@ -40,7 +40,7 @@ class EnablePerformanceMetrics extends ClientCommand { } const {enable = true} = this; - + this.transportActions.enablePerformanceMetrics(enable, callback); } diff --git a/lib/api/client-commands/getPerformanceMetrics.js b/lib/api/client-commands/getPerformanceMetrics.js index be396c9684..9ed95aeefb 100644 --- a/lib/api/client-commands/getPerformanceMetrics.js +++ b/lib/api/client-commands/getPerformanceMetrics.js @@ -38,7 +38,7 @@ class GetPerformanceMetrics extends ClientCommand { return callback(error); } - + this.transportActions.getPerformanceMetrics(callback); } diff --git a/lib/api/client-commands/logs/captureBrowserConsoleLogs.js b/lib/api/client-commands/logs/captureBrowserConsoleLogs.js index aea9312591..e7756ae636 100644 --- a/lib/api/client-commands/logs/captureBrowserConsoleLogs.js +++ b/lib/api/client-commands/logs/captureBrowserConsoleLogs.js @@ -45,7 +45,7 @@ class StartCapturingLogs extends ClientCommand { return callback(error); } - + this.transportActions.startLogsCapture(userCallback, callback); } diff --git a/lib/api/client-commands/logs/captureBrowserExceptions.js b/lib/api/client-commands/logs/captureBrowserExceptions.js index 39adb9fe1c..43bfeafebd 100644 --- a/lib/api/client-commands/logs/captureBrowserExceptions.js +++ b/lib/api/client-commands/logs/captureBrowserExceptions.js @@ -60,4 +60,4 @@ class CatchJsExceptions extends ClientCommand { } } -module.exports = CatchJsExceptions; \ No newline at end of file +module.exports = CatchJsExceptions; diff --git a/lib/api/client-commands/logs/getSessionLogTypes.js b/lib/api/client-commands/logs/getSessionLogTypes.js index c2fd265ea4..13cda02d8f 100644 --- a/lib/api/client-commands/logs/getSessionLogTypes.js +++ b/lib/api/client-commands/logs/getSessionLogTypes.js @@ -9,7 +9,7 @@ const ClientCommand = require('../_base-command.js'); * browser.logs.getSessionLogTypes(function(result) { * const logTypes = result.value; * console.log('Log types available:', logTypes); - * }); + * }); * }); * * it('get log types with ES6 async/await', async function(browser) { diff --git a/lib/api/client-commands/logs/isSessionLogAvailable.js b/lib/api/client-commands/logs/isSessionLogAvailable.js index 163e2e7c00..14231b5123 100644 --- a/lib/api/client-commands/logs/isSessionLogAvailable.js +++ b/lib/api/client-commands/logs/isSessionLogAvailable.js @@ -11,7 +11,7 @@ const ClientCommand = require('../_base-command.js'); * if (isAvailable) { * // do something more in here * } - * }); + * }); * }); * * it('test driver log type with ES6 async/await', async function(browser) { diff --git a/lib/api/client-commands/network/captureRequests.js b/lib/api/client-commands/network/captureRequests.js index 658aab01f2..77aa01312f 100644 --- a/lib/api/client-commands/network/captureRequests.js +++ b/lib/api/client-commands/network/captureRequests.js @@ -49,7 +49,7 @@ class CaptureNetworkCalls extends ClientCommand { return callback(error); } - + this.transportActions.interceptNetworkCalls(userCallback, callback); } @@ -60,4 +60,4 @@ class CaptureNetworkCalls extends ClientCommand { } } -module.exports = CaptureNetworkCalls; \ No newline at end of file +module.exports = CaptureNetworkCalls; diff --git a/lib/api/client-commands/network/mockResponse.js b/lib/api/client-commands/network/mockResponse.js index e38bcbd54b..0ce0977cad 100644 --- a/lib/api/client-commands/network/mockResponse.js +++ b/lib/api/client-commands/network/mockResponse.js @@ -54,7 +54,7 @@ class MockNetworkResponse extends ClientCommand { const slashDel = needsSlash ? '/' : ''; urlToIntercept = `${launchUrl}${slashDel}${urlToIntercept}`; } - + this.transportActions.mockNetworkResponse(urlToIntercept, response, callback); } diff --git a/lib/api/client-commands/network/setConditions.js b/lib/api/client-commands/network/setConditions.js index a3f8f34b70..64e80df09f 100644 --- a/lib/api/client-commands/network/setConditions.js +++ b/lib/api/client-commands/network/setConditions.js @@ -2,7 +2,7 @@ const ClientCommand = require('../_base-command.js'); const {Logger} = require('../../../utils'); /** - * + * * Command to set Chrome network emulation settings. * * @example diff --git a/lib/api/client-commands/pause.js b/lib/api/client-commands/pause.js index 6accd2dadc..695d8a4a18 100644 --- a/lib/api/client-commands/pause.js +++ b/lib/api/client-commands/pause.js @@ -9,11 +9,11 @@ const Debuggability = require('../../utils/debuggability.js'); * - Pause the test execution for the given time in milliseconds. * - Pause the test execution indefinitely, until resumed by pressing a key in terminal. * - Pause the test execution, and then step over to the next test command (execute the next test command) and pause again. - * + * * This command will allow you to pause the test execution in between, hop on to the browser to check the state of your * application (or use DevTools to debug), and once satisfied, either resume the test execution from where it was left * off or step over to the next test command (execute the next test command) and pause again. - * + * * Stepping over to the next test command would allow you to see what exactly changed in your application when the next * test command was executed. You can also use DevTools to monitor those changes, like the network calls that were made * during the execution of that command, etc. @@ -84,7 +84,7 @@ Pause.prototype.command = function(ms, cb) { if (cb) { cb.call(this.client.api); } - + this.emit('complete'); }, ms); } diff --git a/lib/api/client-commands/registerBasicAuth.js b/lib/api/client-commands/registerBasicAuth.js index 715a123534..1b660128d2 100644 --- a/lib/api/client-commands/registerBasicAuth.js +++ b/lib/api/client-commands/registerBasicAuth.js @@ -35,7 +35,7 @@ class RegisterBasicAuth extends ClientCommand { } const {username, password} = this; - + this.transportActions .registerAuth(username, password, callback) .catch(err => { diff --git a/lib/api/client-commands/saveSnapshot.js b/lib/api/client-commands/saveSnapshot.js index dbc37e2920..2c3fceb909 100644 --- a/lib/api/client-commands/saveSnapshot.js +++ b/lib/api/client-commands/saveSnapshot.js @@ -84,4 +84,4 @@ class SaveSnapshot extends ClientCommand { } } -module.exports = SaveSnapshot; \ No newline at end of file +module.exports = SaveSnapshot; diff --git a/lib/api/client-commands/setDeviceDimensions.js b/lib/api/client-commands/setDeviceDimensions.js index e5f16c1583..ddfc94ce89 100644 --- a/lib/api/client-commands/setDeviceDimensions.js +++ b/lib/api/client-commands/setDeviceDimensions.js @@ -59,4 +59,4 @@ class SetDeviceDimensions extends ClientCommand { } } -module.exports = SetDeviceDimensions; \ No newline at end of file +module.exports = SetDeviceDimensions; diff --git a/lib/api/client-commands/takeHeapSnapshot.js b/lib/api/client-commands/takeHeapSnapshot.js index a5e6348d2a..11724d1e88 100644 --- a/lib/api/client-commands/takeHeapSnapshot.js +++ b/lib/api/client-commands/takeHeapSnapshot.js @@ -38,7 +38,7 @@ class TakeHeapSnapshot extends ClientCommand { } const {heapSnapshotLocation} = this; - + this.transportActions.takeHeapSnapshot(heapSnapshotLocation, callback); } diff --git a/lib/api/client-commands/within.js b/lib/api/client-commands/within.js index 872ecc5fda..60931fe6bc 100644 --- a/lib/api/client-commands/within.js +++ b/lib/api/client-commands/within.js @@ -20,4 +20,4 @@ module.exports = class WithinAbstract { static get allowOverride() { return true; } -}; \ No newline at end of file +}; diff --git a/lib/api/element-commands/click.js b/lib/api/element-commands/click.js index 96763ce5ac..7a7a6006a0 100644 --- a/lib/api/element-commands/click.js +++ b/lib/api/element-commands/click.js @@ -66,4 +66,4 @@ class ClickElement extends BaseElementCommand { } } -module.exports = ClickElement; \ No newline at end of file +module.exports = ClickElement; diff --git a/lib/api/element-commands/getFirstElementChild.js b/lib/api/element-commands/getFirstElementChild.js index 35e0445b02..6aff20a5f4 100644 --- a/lib/api/element-commands/getFirstElementChild.js +++ b/lib/api/element-commands/getFirstElementChild.js @@ -23,7 +23,7 @@ const BaseElementCommand = require('./_baseElementCommand.js'); * @api protocol.elements */ class GetFirstElementChild extends BaseElementCommand { - + get extraArgsCount() { return 0; } @@ -35,4 +35,4 @@ class GetFirstElementChild extends BaseElementCommand { } } -module.exports = GetFirstElementChild; \ No newline at end of file +module.exports = GetFirstElementChild; diff --git a/lib/api/element-commands/getLastElementChild.js b/lib/api/element-commands/getLastElementChild.js index b3640414bf..a73cbcf4b3 100644 --- a/lib/api/element-commands/getLastElementChild.js +++ b/lib/api/element-commands/getLastElementChild.js @@ -28,10 +28,10 @@ class GetLastElementChild extends BaseElementCommand { get extraArgsCount() { return 0; } - + async protocolAction() { return this.executeProtocolAction('getLastElementChild'); } } -module.exports = GetLastElementChild; \ No newline at end of file +module.exports = GetLastElementChild; diff --git a/lib/api/element-commands/getNextSibling.js b/lib/api/element-commands/getNextSibling.js index cf54871c85..4f89748939 100644 --- a/lib/api/element-commands/getNextSibling.js +++ b/lib/api/element-commands/getNextSibling.js @@ -23,14 +23,14 @@ const BaseElementCommand = require('./_baseElementCommand.js'); * @exampleLink /api/getNextSibling.js */ class GetNextSibling extends BaseElementCommand { - + get extraArgsCount() { return 0; } - + async protocolAction() { return await this.executeProtocolAction('getNextSibling'); } } -module.exports = GetNextSibling; \ No newline at end of file +module.exports = GetNextSibling; diff --git a/lib/api/element-commands/getPreviousSibling.js b/lib/api/element-commands/getPreviousSibling.js index e0daef3556..953d4d84b6 100644 --- a/lib/api/element-commands/getPreviousSibling.js +++ b/lib/api/element-commands/getPreviousSibling.js @@ -43,14 +43,14 @@ const BaseElementCommand = require('./_baseElementCommand.js'); * @api protocol.elements */ class GetPreviousSibling extends BaseElementCommand { - + get extraArgsCount() { return 0; } - + async protocolAction() { return this.executeProtocolAction('getPreviousSibling'); } } -module.exports = GetPreviousSibling; \ No newline at end of file +module.exports = GetPreviousSibling; diff --git a/lib/api/element-commands/isEnabled.js b/lib/api/element-commands/isEnabled.js index e270d852f1..d0a03a8ebd 100644 --- a/lib/api/element-commands/isEnabled.js +++ b/lib/api/element-commands/isEnabled.js @@ -54,4 +54,4 @@ class IsEnabled extends BaseElementCommand { } -module.exports = IsEnabled; \ No newline at end of file +module.exports = IsEnabled; diff --git a/lib/api/element-commands/isPresent.js b/lib/api/element-commands/isPresent.js index 011127bda9..8bac2f5041 100644 --- a/lib/api/element-commands/isPresent.js +++ b/lib/api/element-commands/isPresent.js @@ -2,7 +2,7 @@ const BaseElementCommand = require('./_baseElementCommand.js'); const {Logger, filterStackTrace} = require('../../utils'); /** * Determines if an element is present in the DOM. - * + * * @example * module.exports = { * demoTest(browser) { @@ -70,4 +70,4 @@ class isPresent extends BaseElementCommand { } -module.exports = isPresent; \ No newline at end of file +module.exports = isPresent; diff --git a/lib/api/element-commands/isSelected.js b/lib/api/element-commands/isSelected.js index 23514aac99..48c97880ca 100644 --- a/lib/api/element-commands/isSelected.js +++ b/lib/api/element-commands/isSelected.js @@ -54,4 +54,4 @@ class IsSelected extends BaseElementCommand { } -module.exports = IsSelected; \ No newline at end of file +module.exports = IsSelected; diff --git a/lib/api/element-commands/setPassword.js b/lib/api/element-commands/setPassword.js index 43dbcd6716..c71a9d0193 100644 --- a/lib/api/element-commands/setPassword.js +++ b/lib/api/element-commands/setPassword.js @@ -47,4 +47,4 @@ class SetPassword extends BaseElementCommand { } } -module.exports = SetPassword; \ No newline at end of file +module.exports = SetPassword; diff --git a/lib/api/element-commands/uploadFile.js b/lib/api/element-commands/uploadFile.js index 2eaa39bc72..ec715406f5 100644 --- a/lib/api/element-commands/uploadFile.js +++ b/lib/api/element-commands/uploadFile.js @@ -32,4 +32,4 @@ class UploadFile extends BaseElementCommand { } -module.exports = UploadFile; \ No newline at end of file +module.exports = UploadFile; diff --git a/lib/api/expect/assertions/_baseAssertion.js b/lib/api/expect/assertions/_baseAssertion.js index 756b1dd7cf..bc492b0926 100644 --- a/lib/api/expect/assertions/_baseAssertion.js +++ b/lib/api/expect/assertions/_baseAssertion.js @@ -147,7 +147,7 @@ class BaseAssertion { init() { const {waitForConditionTimeout, waitForConditionPollInterval, abortOnAssertionFailure} = this.client.api.globals; - let assertions = this.flag('assertions') || 0; + const assertions = this.flag('assertions') || 0; this.flag('assertions', assertions + 1); this.promise = this.flag('promise'); @@ -340,7 +340,7 @@ class BaseAssertion { } getResult(value, fn) { - let result = fn.call(this); + const result = fn.call(this); this.setNegate(); return this.negate ? !result : result; @@ -357,7 +357,7 @@ class BaseAssertion { } getElapsedTime() { - let timeNow = new Date().getTime(); + const timeNow = new Date().getTime(); return timeNow - this.emitter.startTime; } @@ -467,8 +467,8 @@ class BaseAssertion { } '@matchesFlag'(re) { - let adverb = this.hasFlag('that') || this.hasFlag('which'); - let verb = adverb ? 'matches' : 'match'; + const adverb = this.hasFlag('that') || this.hasFlag('which'); + const verb = adverb ? 'matches' : 'match'; this.conditionFlag(re, function() { return re.test(this.resultValue); @@ -483,7 +483,7 @@ class BaseAssertion { conditionFlag(value, conditionFn, arrverb) { this.passed = this.getResult(value, conditionFn); - let verb = this.negate ? arrverb[0]: arrverb[1]; + let verb = this.negate ? arrverb[0] : arrverb[1]; this.expected = `${verb} '${value}'`; this.actual = this.resultValue; @@ -491,7 +491,7 @@ class BaseAssertion { return; } - let needsSpace = this.messageParts.length === 0 ? true : this.messageParts[this.messageParts.length-1].slice(-1) !== ' '; + const needsSpace = this.messageParts.length === 0 ? true : this.messageParts[this.messageParts.length - 1].slice(-1) !== ' '; if (needsSpace) { verb = ' ' + verb; } diff --git a/lib/api/expect/assertions/element/type.js b/lib/api/expect/assertions/element/type.js index f7ec379fab..b02d4f02f2 100644 --- a/lib/api/expect/assertions/element/type.js +++ b/lib/api/expect/assertions/element/type.js @@ -34,7 +34,7 @@ class TypeAssertion extends BaseAssertion { this.article = ['a', 'e', 'i', 'o'].indexOf(type.toString().substring(0, 1)) > -1 ? 'an' : 'a'; this.hasCustomMessage = typeof msg != 'undefined'; this.flag('typeFlag', true); - this.message = msg || 'Expected element %s to ' + (this.negate ? 'not be' : 'be') + ' ' + this.article +' ' + type; + this.message = msg || 'Expected element %s to ' + (this.negate ? 'not be' : 'be') + ' ' + this.article + ' ' + type; this.start(); } diff --git a/lib/api/protocol/elementIdDoubleClick.js b/lib/api/protocol/elementIdDoubleClick.js index ccfbc91b35..3649bfeba3 100644 --- a/lib/api/protocol/elementIdDoubleClick.js +++ b/lib/api/protocol/elementIdDoubleClick.js @@ -5,7 +5,7 @@ const {isFunction} = require('../../utils'); * Move to the element and performs a double-click in the middle of the given element if element is given else double-clicks at the current mouse coordinates (set by `.moveTo()`). * * @method elementIdDoubleClick - * @param {string} webElementId The [Web Element ID](https://www.w3.org/TR/webdriver1/#dfn-web-elements) of the element to route the command to. + * @param {string} webElementId The [Web Element ID](https://www.w3.org/TR/webdriver1/#dfn-web-elements) of the element to route the command to. * @param {function} [callback] Optional callback function to be called when the command finishes. * @api protocol.useractions */ @@ -13,7 +13,7 @@ module.exports = class elementIdDoubleClick extends ProtocolAction { static get isTraceable() { return true; } - + command(webElementId, callback) { if (isFunction(webElementId)) { diff --git a/lib/api/protocol/frame.js b/lib/api/protocol/frame.js index 8c9d78d9b5..00a542c939 100644 --- a/lib/api/protocol/frame.js +++ b/lib/api/protocol/frame.js @@ -28,7 +28,7 @@ const ProtocolAction = require('./_base-action.js'); * @api protocol.frames */ const findElement = function(selector) { - + return new Promise((resolve, reject) => { this.api.findElement({selector, suppressNotFoundErrors: true}, function(res) { if (res.status === -1 && res.error) { diff --git a/lib/api/protocol/moveTo.js b/lib/api/protocol/moveTo.js index 11ca2a01e5..3131b1730a 100644 --- a/lib/api/protocol/moveTo.js +++ b/lib/api/protocol/moveTo.js @@ -48,7 +48,7 @@ module.exports = class Command extends ProtocolAction { ProtocolAction.validateElementId(webElementId); } } - + if (args.length === 1 && isNumber(args[0]) && !isNaN(args[0])) { xoffset = args[0]; } else if (args.length === 2 && isNumber(args[0]) && !isNaN(args[0]) && isNumber(args[1]) && !isNaN(args[1])) { @@ -63,6 +63,6 @@ module.exports = class Command extends ProtocolAction { } return this.transportActions.moveTo(webElementId, xoffset, yoffset, callback); - + } }; diff --git a/lib/api/protocol/releaseMouseButton.js b/lib/api/protocol/releaseMouseButton.js index 2ef6a66120..96e72ba36d 100644 --- a/lib/api/protocol/releaseMouseButton.js +++ b/lib/api/protocol/releaseMouseButton.js @@ -1,7 +1,7 @@ const ProtocolAction = require('./_base-action.js'); /** * Release the depressed left mouse button at the current mouse coordinates (set by `.moveTo()`). - * + * * * @param {function} [callback] Optional callback function to be called when the command finishes. * @api protocol.useractions diff --git a/lib/api/web-element/assert/element-assertions.js b/lib/api/web-element/assert/element-assertions.js index 138b39d5bb..59360c48bc 100644 --- a/lib/api/web-element/assert/element-assertions.js +++ b/lib/api/web-element/assert/element-assertions.js @@ -11,7 +11,7 @@ class ScopedElementAssertions { const assert = this.nightwatchInstance.api.assert; await callback(this.negated ? assert.not : assert, this.scopedElement.webElement); - + return this.scopedElement; } diff --git a/lib/api/web-element/commands/getAccessibleName.js b/lib/api/web-element/commands/getAccessibleName.js index 361180f918..202e2a3d26 100644 --- a/lib/api/web-element/commands/getAccessibleName.js +++ b/lib/api/web-element/commands/getAccessibleName.js @@ -26,4 +26,4 @@ */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementAccessibleName'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getAriaRole.js b/lib/api/web-element/commands/getAriaRole.js index e670d425c8..0f32df12a7 100644 --- a/lib/api/web-element/commands/getAriaRole.js +++ b/lib/api/web-element/commands/getAriaRole.js @@ -25,4 +25,4 @@ */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementAriaRole'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getAttribute.js b/lib/api/web-element/commands/getAttribute.js index 3dcd4a952b..2d47d223cd 100644 --- a/lib/api/web-element/commands/getAttribute.js +++ b/lib/api/web-element/commands/getAttribute.js @@ -29,4 +29,4 @@ */ module.exports.command = function(name) { return this.runQueuedCommandScoped('getElementValue', name); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getCssProperty.js b/lib/api/web-element/commands/getCssProperty.js index 254bc13d5b..cbdb1d83cd 100644 --- a/lib/api/web-element/commands/getCssProperty.js +++ b/lib/api/web-element/commands/getCssProperty.js @@ -40,4 +40,4 @@ */ module.exports.command = function(cssProperty) { return this.runQueuedCommandScoped('getElementCSSValue', cssProperty); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getId.js b/lib/api/web-element/commands/getId.js index c756229a5e..a73b53923e 100644 --- a/lib/api/web-element/commands/getId.js +++ b/lib/api/web-element/commands/getId.js @@ -25,4 +25,4 @@ module.exports.command = function() { return this.runQueuedCommandScoped(function (webElement) { return webElement.getId(); }); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getProperty.js b/lib/api/web-element/commands/getProperty.js index 0c3f2773b2..934f7b158d 100644 --- a/lib/api/web-element/commands/getProperty.js +++ b/lib/api/web-element/commands/getProperty.js @@ -42,4 +42,4 @@ */ module.exports.command = function(name) { return this.runQueuedCommandScoped('getElementProperty', name); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getRect.js b/lib/api/web-element/commands/getRect.js index ab4be35e54..9ecdaaf5ab 100644 --- a/lib/api/web-element/commands/getRect.js +++ b/lib/api/web-element/commands/getRect.js @@ -32,4 +32,4 @@ */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementRect'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getTagName.js b/lib/api/web-element/commands/getTagName.js index 2d6a62c408..f2a06e56cd 100644 --- a/lib/api/web-element/commands/getTagName.js +++ b/lib/api/web-element/commands/getTagName.js @@ -26,4 +26,4 @@ */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementTagName'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getText.js b/lib/api/web-element/commands/getText.js index 78cac96931..f4d56d9420 100644 --- a/lib/api/web-element/commands/getText.js +++ b/lib/api/web-element/commands/getText.js @@ -26,4 +26,4 @@ */ module.exports.command = function() { return this.runQueuedCommandScoped('getElementText'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/getValue.js b/lib/api/web-element/commands/getValue.js index da0c4a9fe9..a1ea155c71 100644 --- a/lib/api/web-element/commands/getValue.js +++ b/lib/api/web-element/commands/getValue.js @@ -26,4 +26,4 @@ */ module.exports.command = function () { return this.getProperty('value'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/rightClick.js b/lib/api/web-element/commands/rightClick.js index d9b0eb9a7b..a31f0e14b4 100644 --- a/lib/api/web-element/commands/rightClick.js +++ b/lib/api/web-element/commands/rightClick.js @@ -24,4 +24,4 @@ */ module.exports.command = function() { return this.runQueuedCommand('contextClick'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/setAttribute.js b/lib/api/web-element/commands/setAttribute.js index 01aeeddfd7..c5464a8a07 100644 --- a/lib/api/web-element/commands/setAttribute.js +++ b/lib/api/web-element/commands/setAttribute.js @@ -27,4 +27,4 @@ module.exports.command = function(name, value) { return this.runQueuedCommand('setElementAttribute', { args: [name, value] }); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/setProperty.js b/lib/api/web-element/commands/setProperty.js index b21153d373..27339bfaf6 100644 --- a/lib/api/web-element/commands/setProperty.js +++ b/lib/api/web-element/commands/setProperty.js @@ -25,4 +25,4 @@ module.exports.command = function(name, value) { return this.runQueuedCommand('setElementProperty', { args: [name, value] }); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/submit.js b/lib/api/web-element/commands/submit.js index 8348b70c3a..0582d00112 100644 --- a/lib/api/web-element/commands/submit.js +++ b/lib/api/web-element/commands/submit.js @@ -25,4 +25,4 @@ */ module.exports.command = function() { return this.runQueuedCommand('elementSubmit'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/takeScreenshot.js b/lib/api/web-element/commands/takeScreenshot.js index 5512e909d5..9f4ab1b200 100644 --- a/lib/api/web-element/commands/takeScreenshot.js +++ b/lib/api/web-element/commands/takeScreenshot.js @@ -26,4 +26,4 @@ */ module.exports.command = function() { return this.runQueuedCommandScoped('takeElementScreenshot'); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/commands/upload.js b/lib/api/web-element/commands/upload.js index 63cd51871d..f4ec3b1b95 100644 --- a/lib/api/web-element/commands/upload.js +++ b/lib/api/web-element/commands/upload.js @@ -27,4 +27,4 @@ module.exports.command = function(file) { return this.runQueuedCommand('uploadFile', { args: [file] }); -}; \ No newline at end of file +}; diff --git a/lib/api/web-element/factory.js b/lib/api/web-element/factory.js index a67a728737..b7e557831d 100644 --- a/lib/api/web-element/factory.js +++ b/lib/api/web-element/factory.js @@ -60,11 +60,11 @@ const createScopedWebElement = function(selector, parentElement, nightwatchInsta nightwatchInstance, ...args }); - + return waitUntil.wait().then(element => resolve(element)); }.bind(instance)), parentElement, nightwatchInstance); } - + }); Object.defineProperty(exported, 'then', { diff --git a/lib/api/web-element/index.js b/lib/api/web-element/index.js index 7a71bb6d1e..4f39928242 100644 --- a/lib/api/web-element/index.js +++ b/lib/api/web-element/index.js @@ -17,4 +17,4 @@ module.exports.root = function(nightwatchInstance) { }; module.exports.createScopedWebElements = Factory.createScopedWebElements; -module.exports.create = Factory.create; \ No newline at end of file +module.exports.create = Factory.create; diff --git a/lib/api/web-element/waitUntil.js b/lib/api/web-element/waitUntil.js index 257e772eef..c6f3a6446f 100644 --- a/lib/api/web-element/waitUntil.js +++ b/lib/api/web-element/waitUntil.js @@ -24,31 +24,31 @@ const mapToSeleniumFunction = { * it ('wait for container', async function(browser){ * // with default implicit timeout of 5000ms (can be overwritten in settings under 'globals.waitForConditionTimeout') * await browser.element.find('#index-container').waitUntil('visible'); - * + * * // with explicit timeout (in milliseconds) * await browser.element.find('#index-container').waitUntil('visible', {timeout: 1000}); - * + * * // continue if failed * await browser.element.find('#index-container').waitUntil('visible', {timeout: 1000, abortOnFailure: false}); - * + * * // with negative assertion * await browser.element.find('#index-container').waitUntil('not.visible'); - * + * * // with xpath as the locate strategy * await browser.element.find(by.xpath('//*[@id="index-container"]')).waitUntil('visible', {message: 'The index container is found.'}); - * + * * // with custom message * await browser.element.find('#index-container').waitUntil('visible', {message: 'The index container is found.'}); * }); - * - * + * + * * it('page object demo Test', async function (browser) { * const nightwatchPage = browser.page.nightwatch(); - * + * * nightwatchPage * .navigate() * .assert.titleContains('Nightwatch.js'); - * + * * await nightwatchPage.element.find('@featuresList').waitUntil('visible'); * }); * }); @@ -98,7 +98,7 @@ class WaitUntil { return result; }); }.bind(this); - + const node = this.scopedElement.queueAction({name: 'waitUntil', createAction}); return node; @@ -110,7 +110,7 @@ class WaitUntil { try { const node = this.createNode(); - + return this.scopedElement.waitFor(node.deferred.promise); } catch (err) { assertApi.ok(false, err.message); @@ -119,13 +119,13 @@ class WaitUntil { formatMsg(message, timeMs) { const defaultMsg = this.message || message; - + return format(defaultMsg, this.selector, timeMs); } assert({result, passed, err, message, elapsedTime}) { const {reporter} = this.scopedElement; - + const runner = new AssertionRunner({abortOnFailure: this.abortOnFailure, passed, err, message, reporter, elapsedTime}); return runner.run(result); @@ -149,7 +149,7 @@ class WaitUntil { fail(result, actual, elapsedTime) { const sliceAction = this.action.split('.'); - + actual = actual ? actual : sliceAction[0] === 'not' ? sliceAction[1] : `not ${this.action}`; const expected = sliceAction[0] === 'not' ? `not ${sliceAction[1]}` : this.action; const message = this.formatMsg(`Timed out while waiting for element <%s> to be ${expected} for %d milliseconds`, this.timeout); @@ -167,4 +167,4 @@ class WaitUntil { } } -module.exports = WaitUntil; \ No newline at end of file +module.exports = WaitUntil; diff --git a/lib/core/asynctree.js b/lib/core/asynctree.js index 317310c494..72152e56b9 100644 --- a/lib/core/asynctree.js +++ b/lib/core/asynctree.js @@ -92,7 +92,7 @@ class AsyncTree extends EventEmitter{ } shouldRejectNodePromise(err, node = this.currentNode) { - if ((err.isExpect|| node.namespace === 'assert') && this.currentNode.isES6Async) { + if ((err.isExpect || node.namespace === 'assert') && this.currentNode.isES6Async) { return true; } diff --git a/lib/core/client.js b/lib/core/client.js index e98e4fbc2b..c25cd030f6 100644 --- a/lib/core/client.js +++ b/lib/core/client.js @@ -85,7 +85,7 @@ class NightwatchAPI { return false; } - return this.platformName.toLowerCase() === platform.toLowerCase(); + return this.platformName.toLowerCase() === platform.toLowerCase(); } isIOS() { @@ -277,7 +277,7 @@ class NightwatchClient extends EventEmitter { let callback; let method; let sessionId = api.sessionId; - const lastArg = args[args.length-1]; + const lastArg = args[args.length - 1]; const isLastArgFunction = Utils.isFunction(lastArg); if (isLastArgFunction) { @@ -528,7 +528,7 @@ class NightwatchClient extends EventEmitter { let value = this.settings.baseUrl || this.settings.launchUrl || this.settings.launch_url || null; // For e2e and component testing on android emulator - if (value && !this.settings.desiredCapabilities.real_mobile && this.settings.desiredCapabilities.avd) { + if (value && !this.settings.desiredCapabilities.real_mobile && this.settings.desiredCapabilities.avd) { value = value.replace('localhost', '10.0.2.2').replace('127.0.0.1', '10.0.2.2'); } diff --git a/lib/core/queue.js b/lib/core/queue.js index 34a973eca6..3e8b3a71bb 100644 --- a/lib/core/queue.js +++ b/lib/core/queue.js @@ -61,7 +61,7 @@ class CommandQueue extends EventEmitter { if (context && context.module && context.module.autoInvoke) { return node; } - + this.tree.addNode(node); if (this.currentNode.done || !this.currentNode.started || initialChildNode) { @@ -119,7 +119,7 @@ class CommandQueue extends EventEmitter { get inProgress() { return this.tree.rootNode.childNodes.length > 0; } - + done(err) { if (this.tree.rootNode.childNodes.length > 0) { return this; diff --git a/lib/element/command.js b/lib/element/command.js index 8fda88135b..5a71187be5 100644 --- a/lib/element/command.js +++ b/lib/element/command.js @@ -274,7 +274,7 @@ class ElementCommand extends EventEmitter { } if (passedArgs < expectedArgs - 1 || passedArgs > expectedArgs) { - const error = new Error(`${this.commandName} method expects ${(expectedArgs - 1)} `+ + const error = new Error(`${this.commandName} method expects ${(expectedArgs - 1)} ` + `(or ${expectedArgs} if using implicit "css selector" strategy) arguments - ${passedArgs} given.`); error.rejectPromise = rejectPromise; @@ -339,7 +339,7 @@ class ElementCommand extends EventEmitter { this.__retryOnFailure = retryAction; } - let {WebdriverElementId} = this.selector; + const {WebdriverElementId} = this.selector; if (WebdriverElementId) { this.WebdriverElementId = WebdriverElementId; } diff --git a/lib/http/formatter.js b/lib/http/formatter.js index fe720e6efd..3d9013d6f2 100644 --- a/lib/http/formatter.js +++ b/lib/http/formatter.js @@ -12,10 +12,10 @@ class ResponseFormatter { */ static jsonStringify(s) { try { - let json = JSON.stringify(s); + const json = JSON.stringify(s); if (json) { return json.replace(jsonRegex, function jsonRegexReplace(c) { - return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4); + return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4); }); } @@ -29,9 +29,9 @@ class ResponseFormatter { } static stripUnknownChars(str) { - let x = []; + const x = []; let i = 0; - let length = str.length; + const length = str.length; for (i; i < length; i++) { if (str.charCodeAt(i)) { @@ -43,9 +43,9 @@ class ResponseFormatter { } static formatHostname(hostname, port, useSSL) { - let isLocalHost = ['127.0.0.1', 'localhost'].indexOf(hostname) > -1; - let protocol = useSSL ? 'https://' : 'http://'; - let isPortDefault = [80, 443].indexOf(port) > -1; + const isLocalHost = ['127.0.0.1', 'localhost'].indexOf(hostname) > -1; + const protocol = useSSL ? 'https://' : 'http://'; + const isPortDefault = [80, 443].indexOf(port) > -1; if (isLocalHost) { return ''; diff --git a/lib/http/request.js b/lib/http/request.js index c03d7f14e8..ce14072ecc 100644 --- a/lib/http/request.js +++ b/lib/http/request.js @@ -218,7 +218,7 @@ class HttpRequest extends EventEmitter { createHttpRequest() { try { - const req = (this.use_ssl ? https: http).request(this.reqOptions, response => { + const req = (this.use_ssl ? https : http).request(this.reqOptions, response => { this.httpResponse = new HttpResponse(response, this); this.httpResponse.on('complete', this.onRequestComplete.bind(this)); this.proxyEvents(this.httpResponse, ['response', 'error', 'success']); diff --git a/lib/index.js b/lib/index.js index f8503c500f..106552e02a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -107,10 +107,10 @@ module.exports.createClient = function({ }); cliRunner.test_settings.disable_global_apis = cliRunner.test_settings.disable_global_apis || !enable_global_apis; - - //merge settings recieved from testsuite to cli runner settings (this might have changed in hooks) + + //merge settings recieved from testsuite to cli runner settings (this might have changed in hooks) lodashMerge(cliRunner.test_settings, test_settings); - + const client = Nightwatch.client(cliRunner.test_settings, reporter, cliRunner.argv, true); // TODO: Do we need this (global `element` api will only be available on diff --git a/lib/page-object/command-wrapper.js b/lib/page-object/command-wrapper.js index 9e640538af..0b40a54bcf 100644 --- a/lib/page-object/command-wrapper.js +++ b/lib/page-object/command-wrapper.js @@ -392,7 +392,7 @@ class CommandLoader { } return originalFn.apply(targetApi, args); - }; + }; } /** diff --git a/lib/reporter/axe-report.js b/lib/reporter/axe-report.js index a3842c56dc..8b5af97479 100644 --- a/lib/reporter/axe-report.js +++ b/lib/reporter/axe-report.js @@ -185,4 +185,4 @@ module.exports = class AxeReport { // eslint-disable-next-line no-console console.log(table.toString()); } -}; \ No newline at end of file +}; diff --git a/lib/reporter/base-reporter.js b/lib/reporter/base-reporter.js index bcc6322f42..618572f1a1 100644 --- a/lib/reporter/base-reporter.js +++ b/lib/reporter/base-reporter.js @@ -39,7 +39,7 @@ module.exports = class BaseReporter { }, {}); module.completedSections = Object.keys(module.completedSections).reduce(function(prev, item) { - if ((module.skippedAtRuntime && module.skippedAtRuntime.includes(item)) || + if ((module.skippedAtRuntime && module.skippedAtRuntime.includes(item)) || (module.skippedByUser && module.skippedByUser.includes(item)) ) { return prev; diff --git a/lib/reporter/global-reporter.js b/lib/reporter/global-reporter.js index f415547d1d..f45f4e8265 100644 --- a/lib/reporter/global-reporter.js +++ b/lib/reporter/global-reporter.js @@ -98,9 +98,9 @@ module.exports = class GlobalReporter { const endTime = new Date().getTime(); this.elapsedTime = endTime - startTime; - + this.globalResults = Results.createGlobalReport(this.suiteResults, initialReport); - this.globalResults.elapsedTime = (this.elapsedTime/1000).toPrecision(4); + this.globalResults.elapsedTime = (this.elapsedTime / 1000).toPrecision(4); this.globalResults.startTimestamp = new Date(startTime).toUTCString(); this.globalResults.endTimestamp = new Date(endTime).toUTCString(); @@ -300,7 +300,7 @@ module.exports = class GlobalReporter { if (!hasCount) { const passedCount = Math.max(0, totalTests - this.globalResults.failed - this.globalResults.errors); // testcases passed - passedMsg = '\n - '+ colors.green(passedCount + '/' + (totalTests > 0 ? totalTests : 'NA')) + ' tests passed'; + passedMsg = '\n - ' + colors.green(passedCount + '/' + (totalTests > 0 ? totalTests : 'NA')) + ' tests passed'; } let skipped = ''; diff --git a/lib/reporter/index.js b/lib/reporter/index.js index e004785061..35d49f54f8 100644 --- a/lib/reporter/index.js +++ b/lib/reporter/index.js @@ -160,11 +160,11 @@ class Reporter extends SimplifiedReporter { logTestCase(testName) { if (this.settings.live_output || !this.settings.parallel_mode) { // eslint-disable-next-line no-console - console.log(`${(!this.settings.silent?'\n\n':'')}\n Running ${colors.green(testName)}${colors.stack_trace(':')}`); + console.log(`${(!this.settings.silent ? '\n\n' : '')}\n Running ${colors.green(testName)}${colors.stack_trace(':')}`); const {columns = 100} = process.stdout; // eslint-disable-next-line no-console - console.log(colors.stack_trace(new Array(Math.max(100, Math.floor(columns/2))).join('─'))); + console.log(colors.stack_trace(new Array(Math.max(100, Math.floor(columns / 2))).join('─'))); //} } else { // eslint-disable-next-line no-console @@ -327,7 +327,7 @@ class Reporter extends SimplifiedReporter { printSimplifiedTestResult(ok, elapsedTime, isWorker) { const {currentTest} = this; - const result = [colors[ok ? 'green': 'red'](Utils.symbols[ok ? 'ok' : 'fail'])]; + const result = [colors[ok ? 'green' : 'red'](Utils.symbols[ok ? 'ok' : 'fail'])]; if (!this.unitTestsMode) { if (isWorker) { result.push(colors.bgBlack.white.bold(this.settings.testEnv)); diff --git a/lib/reporter/reporters/html.js b/lib/reporter/reporters/html.js index c611699251..d168ed3ae4 100644 --- a/lib/reporter/reporters/html.js +++ b/lib/reporter/reporters/html.js @@ -41,7 +41,7 @@ class HtmlReporter extends BaseReporter { getFileName() { let fileName = 'index'; const {filename_format} = this.options; - if (filename_format) { + if (filename_format) { if (typeof filename_format === 'function') { fileName = filename_format(this.results); } else if (typeof filename_format === 'string') { diff --git a/lib/reporter/results.js b/lib/reporter/results.js index c88ea48fc9..1c804d3942 100644 --- a/lib/reporter/results.js +++ b/lib/reporter/results.js @@ -16,7 +16,7 @@ module.exports = class Results { return 'skip'; } - constructor(tests = [], opts, settings, skippedTests=[], allScreenedTests=[]) { + constructor(tests = [], opts, settings, skippedTests = [], allScreenedTests = []) { this.skippedByUser = skippedTests; this.skippedAtRuntime = tests.slice(0); this.testcases = {}; @@ -286,7 +286,7 @@ module.exports = class Results { get retryTest() { return this.__retryTest; } - + /** * @param {TestCase} testcase * @return {Object} @@ -410,7 +410,7 @@ module.exports = class Results { return this; } - + initCount(allScreenedTests) { this.__passedCount = 0; this.__failedCount = 0; @@ -432,7 +432,7 @@ module.exports = class Results { this.time += elapsedTime; if (currentTest) { - this.currentTestResult.time = (elapsedTime/1000).toPrecision(4); + this.currentTestResult.time = (elapsedTime / 1000).toPrecision(4); this.currentTestResult.timeMs = elapsedTime; this.currentTestResult.startTimestamp = new Date(startTime).toUTCString(); this.currentTestResult.endTimestamp = new Date(endTime).toUTCString(); @@ -452,7 +452,7 @@ module.exports = class Results { this.time += elapsedTime; if (currentSection) { - currentSection.time = (elapsedTime/1000).toPrecision(4); + currentSection.time = (elapsedTime / 1000).toPrecision(4); currentSection.timeMs = elapsedTime; currentSection.startTimestamp = startTime; currentSection.endTimestamp = endTime; @@ -466,7 +466,7 @@ module.exports = class Results { const currentTest = this.getCurrentTest(); const currentSection = this.getTestSection(this.currentSectionName); if (!currentTest) { - return; + return; } if (this.hasFailures()) { @@ -489,7 +489,7 @@ module.exports = class Results { setTotalElapsedTime() { this.timeMs = this.time; - this.time = (this.time/1000).toPrecision(4); + this.time = (this.time / 1000).toPrecision(4); return this; } @@ -544,7 +544,7 @@ module.exports = class Results { getTestStatus() { if (this.failedCount > 0 || this.errorsCount > 0) { return Results.TEST_FAIL; - } + } if (this.passedCount > 0) { return Results.TEST_PASS; @@ -556,8 +556,8 @@ module.exports = class Results { /** * Appends data in current testSections data. - * - * @param {Object} data + * + * @param {Object} data */ appendTestResult(data) { lodashMerge(this.testSections, data); diff --git a/lib/reporter/summary.js b/lib/reporter/summary.js index 9d4e5170c4..fdf022f35a 100644 --- a/lib/reporter/summary.js +++ b/lib/reporter/summary.js @@ -26,7 +26,7 @@ module.exports = class Summary { */ static getFailedSuiteContent({testSuite, testSuiteName, index = 0, startSessionEnabled = true}) { const testcases = Object.keys(testSuite.completed); - const initial = [colors.red(` ${Utils.symbols.fail} ${index+1}) ${testSuiteName}`)]; + const initial = [colors.red(` ${Utils.symbols.fail} ${index + 1}) ${testSuiteName}`)]; return testcases.reduce((prev, name) => { const testcase = testSuite.completed[name]; diff --git a/lib/runner/androidEmulator.js b/lib/runner/androidEmulator.js index 4379cca285..e1fe8be1a3 100644 --- a/lib/runner/androidEmulator.js +++ b/lib/runner/androidEmulator.js @@ -13,7 +13,7 @@ module.exports = class AndroidServer { async killEmulator() { return killEmulatorWithoutWait(this.sdkRoot, getPlatformName(), this.emulatorId); } - + async launchEmulator() { try { const emulatorId = await getAlreadyRunningAvd(this.sdkRoot, getPlatformName(), this.avd); diff --git a/lib/runner/cli/argv-setup.js b/lib/runner/cli/argv-setup.js index 36effbf52e..5acad8f487 100644 --- a/lib/runner/cli/argv-setup.js +++ b/lib/runner/cli/argv-setup.js @@ -213,7 +213,7 @@ module.exports = new (function () { : null, this.options.default[key] !== undefined ? '[default: ' + JSON.stringify(this.options.default[key]) + ']' - : null + : null ].filter(Boolean).join(' '); const body = [desc, extra].filter(Boolean).join(' '); @@ -399,7 +399,7 @@ module.exports = new (function () { group: 'Reporting', descriptions: 'Record trace information during nightwatch execution.' }); - + // $ nightwatch --open this.option('open', { group: 'Reporting', diff --git a/lib/runner/cli/cli.js b/lib/runner/cli/cli.js index 6c23a2ac8e..c2de0cac04 100644 --- a/lib/runner/cli/cli.js +++ b/lib/runner/cli/cli.js @@ -24,7 +24,7 @@ class CliRunner { static get CONFIG_FILE_TS() { return './nightwatch.conf.ts'; } - + static createDefaultConfig(destFileName) { // eslint-disable-next-line no-console console.log(Logger.colors.cyan('No config file found in the current working directory, creating nightwatch.conf.js in the current folder...')); @@ -149,7 +149,7 @@ class CliRunner { } } } - + setMobileOptions(argv) { const {desiredCapabilities, selenium = {}} = this.test_settings; @@ -194,7 +194,7 @@ class CliRunner { if (!this.baseSettings) { return this; - } + } this.availableTestEnvs = Object.keys(this.baseSettings.test_settings).filter(key => { return Utils.isObject(this.baseSettings.test_settings[key]); @@ -262,7 +262,7 @@ class CliRunner { test_workers_enabled: this.test_settings.testWorkersEnabled, use_xpath: this.test_settings.use_xpath, is_bstack: this.test_settings.desiredCapabilities['bstack:options'] !== undefined, - test_runner: this.test_settings.test_runner ? this.test_settings.test_runner.type : null + test_runner: this.test_settings.test_runner ? this.test_settings.test_runner.type : null }); } @@ -297,7 +297,7 @@ class CliRunner { if (usingTS) { return path.resolve(CliRunner.CONFIG_FILE_TS); } - + return path.resolve(CliRunner.CONFIG_FILE_JS); } @@ -402,13 +402,13 @@ class CliRunner { for (const env of this.testEnvArray) { const {webdriver = {}} = this.testEnvSettings[env]; const desiredCapabilities = this.testEnvSettings[env].capabilities || this.testEnvSettings[env].desiredCapabilities; - + if (isMobile(desiredCapabilities)) { - + if (Concurrency.isWorker()) { Logger.info('Disabling parallelism while running tests on mobile platform'); } - + return false; } @@ -492,7 +492,7 @@ class CliRunner { return this.runGlobalHook('before', [this.test_settings]) .then(_ => { return this.runGlobalHook('beforeChildProcess', [this.test_settings], true); - }) + }) .then(_ => { return this.getTestsFiles(); }) @@ -628,7 +628,7 @@ class CliRunner { } analyticsCollector.__flush(); - + return errorOrFailed; }); } diff --git a/lib/runner/concurrency/child-process.js b/lib/runner/concurrency/child-process.js index 4fcf7539ad..1eddf4edfa 100644 --- a/lib/runner/concurrency/child-process.js +++ b/lib/runner/concurrency/child-process.js @@ -81,7 +81,7 @@ class ChildProcess extends EventEmitter { writeToStdout(data) { data = data.toString().trim(); - const color_pair = this.availColors[this.index%4]; + const color_pair = this.availColors[this.index % 4]; let output = ''; if (ChildProcess.prevIndex !== this.index) { @@ -148,7 +148,7 @@ class ChildProcess extends EventEmitter { })); } - const color_pair = this.availColors[this.index%4]; + const color_pair = this.availColors[this.index % 4]; this.printLog(' Running: ' + Logger.colors[color_pair[0]][color_pair[1]](` ${this.env_itemKey} `)); diff --git a/lib/runner/concurrency/index.js b/lib/runner/concurrency/index.js index 1caa4580df..fa64d842c7 100644 --- a/lib/runner/concurrency/index.js +++ b/lib/runner/concurrency/index.js @@ -255,7 +255,7 @@ class Concurrency extends EventEmitter { return this.runChildProcess(childProcess, outputLabel, availColors, 'workers') .then(_ => { - remaining -=1; + remaining -= 1; if (remaining > 0) { next(); diff --git a/lib/runner/concurrency/task.js b/lib/runner/concurrency/task.js index 25b89aaf44..f1dc8b0b27 100644 --- a/lib/runner/concurrency/task.js +++ b/lib/runner/concurrency/task.js @@ -16,8 +16,8 @@ function runWorkerTask({argv, port1}) { //send reports to main thread using message port process.port = port1; - + return Nightwatch.runTests(argv, {}); } -module.exports = runWorkerTask; \ No newline at end of file +module.exports = runWorkerTask; diff --git a/lib/runner/concurrency/worker-process.js b/lib/runner/concurrency/worker-process.js index bb6bc9e148..389d6887ff 100644 --- a/lib/runner/concurrency/worker-process.js +++ b/lib/runner/concurrency/worker-process.js @@ -1,5 +1,5 @@ const path = require('path'); -const Piscina= require('piscina'); +const Piscina = require('piscina'); const {isWorkerThread} = Piscina; const EventEmitter = require('events'); const WorkerTask = require('./worker-task'); @@ -20,7 +20,7 @@ class WorkerPool extends EventEmitter { set tasks(tasks) { this.__tasks = tasks; } - + constructor(args, settings, maxWorkerCount) { super(); @@ -44,14 +44,14 @@ class WorkerPool extends EventEmitter { */ addTask({label, argv, colors} = {}) { const workerTask = new WorkerTask({piscina: this.piscina, index: this.index, label, argv, settings: this.settings}); - + workerTask.on('message', (data) => { this.emit('message', data); }); this.index++; this.__tasks.push(workerTask.runWorkerTask(colors)); - + } } diff --git a/lib/runner/concurrency/worker-task.js b/lib/runner/concurrency/worker-task.js index 94aefc6e58..f41a293ffd 100644 --- a/lib/runner/concurrency/worker-task.js +++ b/lib/runner/concurrency/worker-task.js @@ -66,10 +66,10 @@ class WorkerTask extends EventEmitter { async runWorkerTask(colors, type) { this.availColors = colors; - const colorPair = this.availColors[this.index%4]; + const colorPair = this.availColors[this.index % 4]; this.setlabel(colorPair); - this.printLog('Running '+ Logger.colors[colorPair[0]][colorPair[1]](` ${this.task_label} `)); + this.printLog('Running ' + Logger.colors[colorPair[0]][colorPair[1]](` ${this.task_label} `)); const {port1, port2} = new MessageChannel(); port2.onmessage = ({data: result}) => { @@ -112,4 +112,4 @@ class WorkerTask extends EventEmitter { } } -module.exports = WorkerTask; \ No newline at end of file +module.exports = WorkerTask; diff --git a/lib/runner/folder-walk.js b/lib/runner/folder-walk.js index a829ed10dd..d55d046d70 100644 --- a/lib/runner/folder-walk.js +++ b/lib/runner/folder-walk.js @@ -173,7 +173,7 @@ class Walker { if (stat && stat.isFile()) { return fullPath; } - + if (stat && !stat.isDirectory()) { return null; } @@ -273,7 +273,7 @@ class Walker { if (this.disableTs && Utils.isTsFile(resource)) { return null; } - + if (stat && stat.isFile() && Utils.isFileNameValid(resource)) { return path.join(folderPath, resource); } diff --git a/lib/runner/matchers/tags.js b/lib/runner/matchers/tags.js index 3556614a48..cd75571edd 100644 --- a/lib/runner/matchers/tags.js +++ b/lib/runner/matchers/tags.js @@ -44,7 +44,7 @@ class TagsMatcher { const context = new Context({modulePath, settings}); context.setReloadModuleCache(); - + // Defining global browser object to make it available before nightwatch client created. // To avoid errors like browser is not defined if testsuits has tags Object.defineProperty(global, 'browser', { @@ -147,7 +147,7 @@ class TagsMatcher { // when multiple --tag arguments are passed (e.g.: --tag a --tag b) // the resulting array is [a, b], otherwise it is [a] - let tagsArray = Array.isArray(tags) ? tags : [tags]; + const tagsArray = Array.isArray(tags) ? tags : [tags]; // now parse each --tag argument return tagsArray.map(t => TagsMatcher.convertTags(t)); diff --git a/lib/runner/process-listener.js b/lib/runner/process-listener.js index 697851e42a..af5784144e 100644 --- a/lib/runner/process-listener.js +++ b/lib/runner/process-listener.js @@ -111,7 +111,7 @@ module.exports = class { exit() { this.process.exit && this.process.exit(this.exitCode); - + return this; } }; diff --git a/lib/runner/test-runners/cucumber.js b/lib/runner/test-runners/cucumber.js index cf4f79dbe1..6402ec3478 100644 --- a/lib/runner/test-runners/cucumber.js +++ b/lib/runner/test-runners/cucumber.js @@ -96,7 +96,7 @@ class CucumberSuite extends TestSuite { options.feature_path = [options.feature_path]; } const {feature_path = ''} = options; - const parallelArgs = this.usingCucumberWorkers ? ['--parallel', this.usingCucumberWorkers]: []; + const parallelArgs = this.usingCucumberWorkers ? ['--parallel', this.usingCucumberWorkers] : []; const additionalOptions = this.buildArgvValue(['tags', 'retry-tag-filter', 'profile', 'format', 'format-options', 'dry-run', 'fail-fast', ['retry', 'retries'], 'no-strict', 'name']); const extraParams = ['--world-parameters', JSON.stringify({...this.argv, settings: this.settings})]; @@ -147,7 +147,7 @@ class CucumberSuite extends TestSuite { ...this.argv }; - if ((isDefined(allArgv[argName]) && allArgv[argName] !== '') || + if ((isDefined(allArgv[argName]) && allArgv[argName] !== '') || (isDefined(allArgv[key]) && allArgv[key] !== '') ) { let argValues = allArgv[argName] || allArgv[key]; diff --git a/lib/runner/test-runners/mocha.js b/lib/runner/test-runners/mocha.js index d601b02e4a..3af11a28be 100644 --- a/lib/runner/test-runners/mocha.js +++ b/lib/runner/test-runners/mocha.js @@ -118,7 +118,7 @@ class MochaRunner { if (this.isTestWorker()) { const filePath = this.argv.test; - const reportFilename = filePath.substring(filePath.lastIndexOf('/')+1).split('.')[0]; + const reportFilename = filePath.substring(filePath.lastIndexOf('/') + 1).split('.')[0]; this.mochaOpts.isWorker = true; if (argv.reporter.includes('mocha-junit-reporter')) { @@ -194,7 +194,7 @@ class MochaRunner { const client = mochaSuite && mochaSuite.client; if (client && client.sessionId) { - let request = client.transport.createHttpRequest({ + const request = client.transport.createHttpRequest({ path: `/session/${client.sessionId}` }); diff --git a/lib/runner/test-runners/mocha/custom-runnable.js b/lib/runner/test-runners/mocha/custom-runnable.js index 1deb22eea0..6ee53db00b 100644 --- a/lib/runner/test-runners/mocha/custom-runnable.js +++ b/lib/runner/test-runners/mocha/custom-runnable.js @@ -1,7 +1,7 @@ module.exports = async function(fn, isHook = false) { - let self = this; - let start = new Date(); - let ctx = this.ctx; + const self = this; + const start = new Date(); + const ctx = this.ctx; let finished; if (this.isPending()) { @@ -24,7 +24,7 @@ module.exports = async function(fn, isHook = false) { return; } emitted = true; - let msg = 'done() called multiple times'; + const msg = 'done() called multiple times'; if (err && err.message) { err.message += ` (and Mocha's ${msg})`; self.emit('error', err); @@ -35,7 +35,7 @@ module.exports = async function(fn, isHook = false) { // finished function done(err) { - let ms = self.timeout(); + const ms = self.timeout(); if (self.timedOut) { return; } @@ -125,4 +125,4 @@ module.exports = async function(fn, isHook = false) { done(err); emitted = true; } -}; \ No newline at end of file +}; diff --git a/lib/runner/test-runners/mocha/custom-runner.js b/lib/runner/test-runners/mocha/custom-runner.js index b9efc84732..f2c546c054 100644 --- a/lib/runner/test-runners/mocha/custom-runner.js +++ b/lib/runner/test-runners/mocha/custom-runner.js @@ -76,4 +76,4 @@ module.exports = class CustomRunner extends Mocha.Runner { super.run(fn); } -}; \ No newline at end of file +}; diff --git a/lib/runner/test-runners/mocha/extensions.js b/lib/runner/test-runners/mocha/extensions.js index 882b65cdba..62deab2134 100644 --- a/lib/runner/test-runners/mocha/extensions.js +++ b/lib/runner/test-runners/mocha/extensions.js @@ -100,4 +100,4 @@ module.exports = class Extensions { suite.timeout(30000); } } -}; \ No newline at end of file +}; diff --git a/lib/runner/test-runners/mocha/nightwatchSuite.js b/lib/runner/test-runners/mocha/nightwatchSuite.js index a7a7573777..53d65422e8 100644 --- a/lib/runner/test-runners/mocha/nightwatchSuite.js +++ b/lib/runner/test-runners/mocha/nightwatchSuite.js @@ -121,4 +121,4 @@ module.exports.init = function({suite, nightwatchSuite}) { console.error(err); process.exit(1); }); -}; \ No newline at end of file +}; diff --git a/lib/runner/test-source.js b/lib/runner/test-source.js index b764cd4824..7bdcaa4db0 100644 --- a/lib/runner/test-source.js +++ b/lib/runner/test-source.js @@ -66,15 +66,15 @@ class TestSource { return jsonFile; } - + getTestSourceForRerunFailed() { const {reporter_options: {minimal_report_file_path}} = this.settings; const minimalJsonFile = this.getRerunFailedFile(minimal_report_file_path); - + try { const {modules = {}} = require(minimalJsonFile); const testsource = []; - + Object.keys(modules).forEach(moduleKey => { if (modules[moduleKey] && modules[moduleKey].status === 'fail') { testsource.push(modules[moduleKey].modulePath); @@ -111,7 +111,7 @@ class TestSource { if ((process.env.NIGHTWATCH_RERUN_FAILED === 'true' || this.argv['rerun-failed']) && Concurrency.isMasterProcess()) { return this.getTestSourceForRerunFailed(this.argv); } - + if (this.argv['test-worker'] || singleSourceFile(this.argv)) { return this.getTestSourceForSingle(this.argv.test || this.argv._source); } @@ -140,10 +140,10 @@ class TestSource { return groupTestsource; } // only when all groups fail to match will there be a run error - let testsource = groupTestsource.filter(Utils.dirExistsSync); + const testsource = groupTestsource.filter(Utils.dirExistsSync); if (!this.settings.silent) { - let ignoredSource = groupTestsource.filter(entry => testsource.indexOf(entry) === -1); + const ignoredSource = groupTestsource.filter(entry => testsource.indexOf(entry) === -1); if (ignoredSource.length) { Logger.warn('The following group paths were not found and will be excluded from the run:\n - ' + @@ -168,11 +168,11 @@ class TestSource { } if (this.settings.exclude) { - let arrExclude = Array.isArray(this.settings.exclude) ? this.settings.exclude : [this.settings.exclude]; - let resolvedExclude = arrExclude.map(item => path.resolve(item)); + const arrExclude = Array.isArray(this.settings.exclude) ? this.settings.exclude : [this.settings.exclude]; + const resolvedExclude = arrExclude.map(item => path.resolve(item)); this.src_folders = this.src_folders.filter(item => { - let resolvedPath = path.resolve(item); + const resolvedPath = path.resolve(item); let match = true; resolvedExclude.forEach(function(pattern) { @@ -191,13 +191,13 @@ class TestSource { * @return {Array} */ findGroupPath(groupName) { - let fullGroupPath = path.resolve(groupName); + const fullGroupPath = path.resolve(groupName); // for each src folder, append the group to the path // to resolve the full test path return this.src_folders.map(function(srcFolder) { - let fullSrcFolder = path.resolve(srcFolder); + const fullSrcFolder = path.resolve(srcFolder); if (fullGroupPath.indexOf(fullSrcFolder) === 0) { return groupName; } diff --git a/lib/settings/defaults.js b/lib/settings/defaults.js index d7aed546c0..7eeb82b2fe 100644 --- a/lib/settings/defaults.js +++ b/lib/settings/defaults.js @@ -60,7 +60,7 @@ module.exports = { // An object which will be made available on the main test api, throughout the test execution globals: { - + // this controls whether to abort the test execution when an assertion failed and skip the rest // it's being used in waitFor commands and expect assertions abortOnAssertionFailure: true, diff --git a/lib/settings/settings.js b/lib/settings/settings.js index cbaaef6ea4..de6901211d 100644 --- a/lib/settings/settings.js +++ b/lib/settings/settings.js @@ -398,7 +398,7 @@ class Settings { } inheritFromSuperEnv(testEnvSettings) { - if (testEnvSettings.extends) { + if (testEnvSettings.extends) { const superEnv = this.baseSettings.test_settings[testEnvSettings.extends] || {}; delete testEnvSettings.extends; defaultsDeep(testEnvSettings, superEnv); diff --git a/lib/testsuite/hooks/afterAll.js b/lib/testsuite/hooks/afterAll.js index 9e5a54804d..1b58eed586 100644 --- a/lib/testsuite/hooks/afterAll.js +++ b/lib/testsuite/hooks/afterAll.js @@ -6,4 +6,4 @@ class AfterAll extends BaseHook { } } -module.exports = AfterAll; \ No newline at end of file +module.exports = AfterAll; diff --git a/lib/testsuite/hooks/afterEach.js b/lib/testsuite/hooks/afterEach.js index 077d513828..bcb49c490d 100644 --- a/lib/testsuite/hooks/afterEach.js +++ b/lib/testsuite/hooks/afterEach.js @@ -6,4 +6,4 @@ class AfterEach extends BaseHook { } } -module.exports = AfterEach; \ No newline at end of file +module.exports = AfterEach; diff --git a/lib/testsuite/hooks/beforeAll.js b/lib/testsuite/hooks/beforeAll.js index 2a1d766b61..b97945ce06 100644 --- a/lib/testsuite/hooks/beforeAll.js +++ b/lib/testsuite/hooks/beforeAll.js @@ -10,4 +10,4 @@ class BeforeAll extends BaseHook { } } -module.exports = BeforeAll; \ No newline at end of file +module.exports = BeforeAll; diff --git a/lib/testsuite/hooks/beforeEach.js b/lib/testsuite/hooks/beforeEach.js index 3b2b0c62a3..1a301c9576 100644 --- a/lib/testsuite/hooks/beforeEach.js +++ b/lib/testsuite/hooks/beforeEach.js @@ -10,4 +10,4 @@ class BeforeAll extends BaseHook { } } -module.exports = BeforeAll; \ No newline at end of file +module.exports = BeforeAll; diff --git a/lib/testsuite/index.js b/lib/testsuite/index.js index e8e7c85a65..df45206fbe 100644 --- a/lib/testsuite/index.js +++ b/lib/testsuite/index.js @@ -144,8 +144,8 @@ class TestSuite { validateNightwatchInspectorCriteria() { return ( - this.argv.debug && - Concurrency.isMasterProcess() && + this.argv.debug && + Concurrency.isMasterProcess() && this.client.api.isChrome() ); } @@ -451,7 +451,7 @@ class TestSuite { runHook(hookName) { Logger.log(`${Logger.colors.green('→')} Running [${hookName}]:`); - + if (hookName === 'before' || hookName === 'after') { this.client.reporter.setCurrentSection({testName: `__${hookName}_hook`}); } @@ -471,14 +471,14 @@ class TestSuite { } this.client.reporter.setCurrentSection({testName: `__global_${hookName}_hook`}); - + return this.handleRunnable(hookName, async () => { if (this.globalsInstance) { await this.globalsInstance.runPluginHook(hookName, [this.settings]); } const result = await this.globalHooks[hookName].run(this.client); - + this.onTestSectionFinished(); return result; @@ -547,7 +547,7 @@ class TestSuite { .then(() => this.runHook('before')) .then(result => { this.onTestSectionFinished(); - + if (result instanceof Error) { Logger.error(result); } @@ -683,13 +683,13 @@ class TestSuite { if (Concurrency.isWorker()) { this.sendReportToParentWorker(); } - + return failures; } - + async sessionFinished(reason) { let lastError = null; - + if (reason === 'FAILED' || reason === 'RETRY_SUITE') { lastError = this.reporter.testResults.lastError; } @@ -719,7 +719,7 @@ class TestSuite { return potentialError; } - + if (endSession) { const runnable = new Runnable('terminate', _ => { if (this.api && isFunction(this.api.end)) { @@ -805,7 +805,7 @@ class TestSuite { if (this.transport.driverService && this.reporter.testResults) { this.reporter.testResults.setSeleniumLogFile(this.transport.driverService.getSeleniumOutputFilePath()); } - + // if there was an error in the testcase and skip_testcases_on_fail, we must send it forward, but after we run afterEach and after hooks return this.runHook('afterEach') .then(() => this.testCaseFinished()) @@ -876,10 +876,10 @@ class TestSuite { if (!err && this.transport.isResultSuccess(result)) { const assertions = this.api.currentTest.results.assertions || []; const commands = this.reporter.currentSection.commands || []; - + if (assertions.length > 0) { - const currentAssertion = assertions[assertions.length-1]; - const currentCommand = commands[commands.length-1]; + const currentAssertion = assertions[assertions.length - 1]; + const currentCommand = commands[commands.length - 1]; if (currentAssertion) { currentAssertion.screenshots = currentAssertion.screenshots || []; @@ -903,7 +903,7 @@ class TestSuite { takeSnapshot(node) { const commands = this.reporter.currentSection.commands || []; - const currentCommand = commands[commands.length-1]; + const currentCommand = commands[commands.length - 1]; if (this.settings.trace.enabled && node.isTraceable) { const snapShotPath = Snapshots.getFileName({ @@ -1047,11 +1047,11 @@ class TestSuite { // eslint-disable-next-line no-console (this.context.isDisabled() ? Logger.info : console.log)(Logger.colors.cyan('[' + this.context.moduleKey + ']')); } else { - Logger[this.context.isDisabled() ? 'info': 'logDetailedMessage'](`\n${Logger.colors.cyan(testSuiteDisplay)}`); + Logger[this.context.isDisabled() ? 'info' : 'logDetailedMessage'](`\n${Logger.colors.cyan(testSuiteDisplay)}`); } if (!this.context.unitTestingMode) { - Logger[this.context.isDisabled() ? 'info': 'logDetailedMessage'](Logger.colors.purple(new Array(Math.min(testSuiteDisplay.length*2 + 1, 80)).join('─'))); + Logger[this.context.isDisabled() ? 'info' : 'logDetailedMessage'](Logger.colors.purple(new Array(Math.min(testSuiteDisplay.length * 2 + 1, 80)).join('─'))); } } diff --git a/lib/testsuite/nightwatch-inspector/index.js b/lib/testsuite/nightwatch-inspector/index.js index 5c977a5ac6..379f343b80 100644 --- a/lib/testsuite/nightwatch-inspector/index.js +++ b/lib/testsuite/nightwatch-inspector/index.js @@ -21,7 +21,7 @@ module.exports = class NightwatchInspectorServer extends WebSocket { const {desiredCapabilities} = this.client.settings; const chromeOptions = desiredCapabilities['goog:chromeOptions']; const {args = []} = chromeOptions || {}; - + desiredCapabilities['goog:chromeOptions'] = { ...chromeOptions, extensions: [crxfile], @@ -55,13 +55,13 @@ module.exports = class NightwatchInspectorServer extends WebSocket { getNightwatchCommands() { const {api} = this.client; const {assert, expect, verify, ensure} = api; - + return [ 'browser', ...[api, assert, expect, verify, ensure].reduce((keys, obj) => keys.concat(Object.keys(obj)), []) ]; } - + async executeCommands(data) { let result; const context = {browser: this.client.api}; diff --git a/lib/testsuite/nightwatch-inspector/websocket-server.js b/lib/testsuite/nightwatch-inspector/websocket-server.js index eaff5583a6..b814c70094 100644 --- a/lib/testsuite/nightwatch-inspector/websocket-server.js +++ b/lib/testsuite/nightwatch-inspector/websocket-server.js @@ -21,7 +21,7 @@ module.exports = class Websocket { this._wss.on('error', (error) => { this.handleSocketError(error, cb); }); - + this._wss.on('listening', () => { Logger.log(`WebSocket server is listening on port ${this.portNumber}`); }); diff --git a/lib/transport/selenium-webdriver/browserstack/appAutomate.js b/lib/transport/selenium-webdriver/browserstack/appAutomate.js index 988a57e766..dcb44e6a8a 100644 --- a/lib/transport/selenium-webdriver/browserstack/appAutomate.js +++ b/lib/transport/selenium-webdriver/browserstack/appAutomate.js @@ -74,7 +74,7 @@ class AppAutomate extends BrowserStack { // eslint-disable-next-line no-console console.log(Logger.colors.green(Utils.symbols.ok), Logger.colors.stack_trace('App upload successful!'), '\n'); - + if (!response.custom_id) { // custom_id not being used options['appium:app'] = response.app_url; diff --git a/lib/transport/selenium-webdriver/browserstack/browserstack.js b/lib/transport/selenium-webdriver/browserstack/browserstack.js index d757c790c9..f20eae6ace 100644 --- a/lib/transport/selenium-webdriver/browserstack/browserstack.js +++ b/lib/transport/selenium-webdriver/browserstack/browserstack.js @@ -48,8 +48,8 @@ class Browserstack extends AppiumBaseServer { // checking for legacy-ways for providing config this.settings.desiredCapabilities['bstack:options'] = defaultsDeep(this.settings.desiredCapabilities['bstack:options'], { - userName: desiredCapabilities['browserstack.user'], - accessKey: desiredCapabilities['browserstack.key'], + userName: desiredCapabilities['browserstack.user'], + accessKey: desiredCapabilities['browserstack.key'], buildName: desiredCapabilities.build || desiredCapabilities.buildName, local: desiredCapabilities['browserstack.local'], sessionName: desiredCapabilities['name'] @@ -141,7 +141,7 @@ class Browserstack extends AppiumBaseServer { super.sessionFinished(reason); await this.testSuiteFinished(err); } - + async testSuiteFinished(err) { try { if (this.sessionId) { diff --git a/lib/transport/selenium-webdriver/cdp.js b/lib/transport/selenium-webdriver/cdp.js index d48a8a42e9..06bf9c20a9 100644 --- a/lib/transport/selenium-webdriver/cdp.js +++ b/lib/transport/selenium-webdriver/cdp.js @@ -1,5 +1,5 @@ class Cdp { - async getConnection(driver, reset=false) { + async getConnection(driver, reset = false) { if (!reset && this._connection) { return this._connection; } diff --git a/lib/transport/selenium-webdriver/httpclient.js b/lib/transport/selenium-webdriver/httpclient.js index d4084ecdfa..c7c9f0129b 100644 --- a/lib/transport/selenium-webdriver/httpclient.js +++ b/lib/transport/selenium-webdriver/httpclient.js @@ -18,12 +18,12 @@ module.exports = function(settings, HttpResponse) { const {log_screenshot_data} = settings; let {port} = options; if (port) { - port = Number(port); + port = Number(port); HttpRequest.updateGlobalSettings({port}); } else { - port = protocol === 'https' ? 443 : 80; + port = protocol === 'https' ? 443 : 80; } - + this.options = { host, port, @@ -34,7 +34,7 @@ module.exports = function(settings, HttpResponse) { use_ssl: protocol === 'https:' }; this.errorTimeoutId = null; - + } /** @override */ diff --git a/lib/transport/selenium-webdriver/index.js b/lib/transport/selenium-webdriver/index.js index 0a08bf01a0..76ad5d92ee 100644 --- a/lib/transport/selenium-webdriver/index.js +++ b/lib/transport/selenium-webdriver/index.js @@ -64,7 +64,7 @@ class Transport extends BaseTransport { static set driverService(value) { _driverService = value; } - + /** * @override @@ -222,9 +222,9 @@ class Transport extends BaseTransport { if (value) { return Transport.driver; } - + Transport.driver = await this.createDriver({options}); - + return Transport.driver; } @@ -235,7 +235,7 @@ class Transport extends BaseTransport { } try { await Transport.driver.getSession(); - + return true; } catch (err) { return false; @@ -293,10 +293,10 @@ class Transport extends BaseTransport { const session = new Session(this.driver); const sessionExports = await session.exported(); const {sessionInfo, sessionId, capabilities, elementKey} = sessionExports; - + this.__elementKey = elementKey; await this.showConnectInfo({startTime, host, port, start_process, sessionInfo}); - + return { sessionId, capabilities diff --git a/lib/transport/selenium-webdriver/method-mappings.js b/lib/transport/selenium-webdriver/method-mappings.js index eef70c1b3c..33a6a1dff5 100644 --- a/lib/transport/selenium-webdriver/method-mappings.js +++ b/lib/transport/selenium-webdriver/method-mappings.js @@ -647,7 +647,7 @@ module.exports = class MethodMappings { async clickElement(webElementOrId) { const element = this.getWebElement(webElementOrId); await element.click(); - + return null; }, @@ -881,7 +881,7 @@ module.exports = class MethodMappings { return null; }, - async contextClick(webElementOrId) { + async contextClick(webElementOrId) { const element = this.getWebElement(webElementOrId); await this.driver.actions({async: true}).contextClick(element).perform(); @@ -889,17 +889,17 @@ module.exports = class MethodMappings { }, async pressAndHold(webElementOrId) { - + const element = this.getWebElement(webElementOrId); await this.driver.actions({async: true}).move({origin: element}).press().perform(); - + return null; }, async release(webElementOrId) { await this.driver.actions({async: true}).release().perform(); - - return null; + + return null; }, /////////////////////////////////////////////////////////// // User Prompts @@ -1155,7 +1155,7 @@ module.exports = class MethodMappings { async mockNetworkResponse(urlToIntercept, response) { const cdpConnection = await cdp.getConnection(this.driver); - const {status=200, headers: headersObject, body: bodyPlain=''} = response; + const {status = 200, headers: headersObject, body: bodyPlain = ''} = response; const headers = []; if (headersObject) { for (const [name, value] of Object.entries(headersObject)) { @@ -1209,29 +1209,29 @@ module.exports = class MethodMappings { async takeHeapSnapshot(heapSnapshotLocation) { const cdpConnection = await cdp.getConnection(this.driver); - + const chunks = []; cdpConnection._wsConnection.on('message', (message) => { const params = JSON.parse(message); if (params.method === 'HeapProfiler.addHeapSnapshotChunk') { const chunk = params['params']['chunk']; - + chunks.push(chunk); } }); - + await cdpConnection.execute( 'HeapProfiler.enable', {} ); - + await cdpConnection.execute( 'HeapProfiler.takeHeapSnapshot', {} ); - + let prevChunks = []; - + return new Promise((resolve) => { const intervalId = setInterval(() => { if (prevChunks.length !== 0 && prevChunks.length === chunks.length) { @@ -1239,15 +1239,15 @@ module.exports = class MethodMappings { } prevChunks = [...chunks]; }, 100); - + const resolveAndClearInterval = () => { clearInterval(intervalId); - + const heapSnapshot = chunks.join(''); if (heapSnapshotLocation) { fs.writeFileSync(heapSnapshotLocation, heapSnapshot); } - + resolve({value: heapSnapshot}); }; }); diff --git a/lib/transport/selenium-webdriver/session.js b/lib/transport/selenium-webdriver/session.js index 02d1dab6ed..9062246be6 100644 --- a/lib/transport/selenium-webdriver/session.js +++ b/lib/transport/selenium-webdriver/session.js @@ -4,9 +4,9 @@ module.exports = class Session { } static serializeCapabilities(caps) { - let ret = {}; - for (let key of caps.keys()) { - let cap = caps.get(key); + const ret = {}; + for (const key of caps.keys()) { + const cap = caps.get(key); if (cap !== undefined && cap !== null) { ret[key] = cap; } @@ -45,4 +45,4 @@ module.exports = class Session { capabilities: Session.serializeCapabilities(sessionCapabilities) }; } -}; \ No newline at end of file +}; diff --git a/lib/utils/addDetailedError.ts b/lib/utils/addDetailedError.ts index 0977c1ee66..dbaee47a4d 100644 --- a/lib/utils/addDetailedError.ts +++ b/lib/utils/addDetailedError.ts @@ -58,4 +58,4 @@ export = function(err: NightwatchError) { if (detailedErr) { err.detailedErr = detailedErr; } -}; \ No newline at end of file +}; diff --git a/lib/utils/analytics.js b/lib/utils/analytics.js index 80f10cc03d..890b4b87fc 100644 --- a/lib/utils/analytics.js +++ b/lib/utils/analytics.js @@ -40,7 +40,7 @@ const SYSTEM_LANGUAGE = getLanguage(); /** * See: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide */ -class AnalyticsCollector { +class AnalyticsCollector { constructor() { this.queueLength = 0; this.parameters = {}; @@ -113,7 +113,7 @@ class AnalyticsCollector { return await this.__addToQueue(name, parameters); } - + async collectErrorEvent(error, isUncaught = false) { if (!error) { return; @@ -186,7 +186,7 @@ class AnalyticsCollector { this.logger.info('Analytics flush error:', error.message); } } - + async __addToQueue(eventType, parameters) { if (!this.settings.usage_analytics.enabled) { return; @@ -256,7 +256,7 @@ class AnalyticsCollector { return `/mp/collect?api_secret=${apiKey}&measurement_id=${trackingId}`; } - + async __logAnalyticsEvents(data) { const logfile = this.__getLogFileLocation(); @@ -267,7 +267,7 @@ class AnalyticsCollector { data.params['first_run'] = true; await fs.mkdir(path.dirname(logfile), {recursive: true}); - } + } const writeFn = hasAnalyticsLog ? fs.appendFile : fs.writeFile; @@ -327,7 +327,7 @@ function getLanguage() { getWindowsLanguageCode() || '??'); } - + /** * Attempt to get the Windows Language Code string. */ @@ -356,4 +356,4 @@ function buildUserAgentString() { } // export singleton instance -module.exports = new AnalyticsCollector();; \ No newline at end of file +module.exports = new AnalyticsCollector();; diff --git a/lib/utils/debuggability.js b/lib/utils/debuggability.js index aa9455bfc4..ed291e2640 100644 --- a/lib/utils/debuggability.js +++ b/lib/utils/debuggability.js @@ -6,7 +6,7 @@ class Debuggability { static set stepOverAndPause(value) { this._stepOverAndPause = value; } - + static reset() { this._stepOverAndPause = false; } diff --git a/lib/utils/getAllClassMethodNames.js b/lib/utils/getAllClassMethodNames.js index 1cf79b0a95..127bb49dba 100644 --- a/lib/utils/getAllClassMethodNames.js +++ b/lib/utils/getAllClassMethodNames.js @@ -24,4 +24,4 @@ module.exports = function(instance, additionalReserved = []) { } return [...result]; -}; \ No newline at end of file +}; diff --git a/lib/utils/index.js b/lib/utils/index.js index fe4b6d7feb..3b5d031d42 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -151,11 +151,11 @@ class Utils { } static formatElapsedTime(timeMs, includeMs = false) { - const seconds = timeMs/1000; + const seconds = timeMs / 1000; return (seconds < 1 && timeMs + 'ms') || (seconds > 1 && seconds < 60 && (seconds + 's')) || - (Math.floor(seconds/60) + 'm' + ' ' + Math.floor(seconds%60) + 's' + (includeMs ? (' / ' + timeMs + 'ms') : '')); + (Math.floor(seconds / 60) + 'm' + ' ' + Math.floor(seconds % 60) + 's' + (includeMs ? (' / ' + timeMs + 'ms') : '')); } /** @@ -200,7 +200,7 @@ class Utils { return ''; } - return (offset > 0 && (string.charAt(offset-1) !== ' ') ? ' ':'') + $1; + return (offset > 0 && (string.charAt(offset - 1) !== ' ') ? ' ' : '') + $1; }); const words = moduleName.split(nameSeparatorRegxp).map(function(word, index, matches) { @@ -261,7 +261,7 @@ class Utils { } } parentFolder = this.isFileNameValid(parentFolder) ? '' : parentFolder; - + return path.join(parentFolder, diffInFolder, moduleName); } @@ -526,7 +526,7 @@ class Utils { /** * Writes content to file. Creates parent folders if the folders do not exist. * @param {string} filePath - * @param {string} data + * @param {string} data */ static writeToFile(filePath, data, encoding = null) { const dir = path.resolve(filePath, '..'); @@ -578,7 +578,7 @@ class Utils { if (Utils.fileExistsSync(projectTsFileLocation1)) { return projectTsFileLocation1; - } + } if (Utils.fileExistsSync(projectTsFileLocation2)) { return projectTsFileLocation2; } @@ -630,7 +630,7 @@ class Utils { static isLocalhost(webdriver = {}) { const {host} = webdriver; - + return ['127.0.0.1', 'localhost'].indexOf(host) > -1; } @@ -644,7 +644,7 @@ class Utils { return fn; } - + static stringifyObject(objects) { const objectString = Utils.isObject(objects) ? inspect(objects) : objects; diff --git a/lib/utils/locatestrategy.js b/lib/utils/locatestrategy.js index 65e8862a85..fdb88d16d5 100644 --- a/lib/utils/locatestrategy.js +++ b/lib/utils/locatestrategy.js @@ -46,4 +46,4 @@ class LocateStrategy { } } -module.exports = LocateStrategy; \ No newline at end of file +module.exports = LocateStrategy; diff --git a/lib/utils/logger/index.js b/lib/utils/logger/index.js index afd03c3fd8..455770520a 100644 --- a/lib/utils/logger/index.js +++ b/lib/utils/logger/index.js @@ -400,7 +400,7 @@ class Logger { if (errorObj.help) { content.push(this.colors.brown('\n Try fixing by :')); errorObj.help.forEach((step, index) => { - content.push(` ${this.colors.blue(index+1)}. ${step}`); + content.push(` ${this.colors.blue(index + 1)}. ${step}`); }); } diff --git a/lib/utils/logger/log_settings.js b/lib/utils/logger/log_settings.js index ae38580660..378cd9f47c 100644 --- a/lib/utils/logger/log_settings.js +++ b/lib/utils/logger/log_settings.js @@ -100,4 +100,4 @@ module.exports = new (function() { } return new LogSettings(); -})(); \ No newline at end of file +})(); diff --git a/lib/utils/mobile.js b/lib/utils/mobile.js index 9d74c08cd4..2799b3b298 100644 --- a/lib/utils/mobile.js +++ b/lib/utils/mobile.js @@ -16,7 +16,7 @@ function requireMobileHelper() { } else if (!semver.satisfies(process.version, '>=14.0.0')) { err.message = 'You are using Node ' + process.version + ', but @nightwatch/mobile-helper requires Node >= v14.0.0.\nPlease upgrade your Node version.'; } - + err.showTrace = false; err.displayed = false; @@ -26,7 +26,7 @@ function requireMobileHelper() { /** * check if target is Android - * @param {Object} desiredCapabilities + * @param {Object} desiredCapabilities * @returns {Boolean} */ function isAndroid(desiredCapabilities = {}){ @@ -47,7 +47,7 @@ function isAndroid(desiredCapabilities = {}){ /** * check if target is iOS Device - * @param {Object} desiredCapabilities + * @param {Object} desiredCapabilities * @returns {Boolean} */ function isIos(desiredCapabilities = {}) { @@ -62,7 +62,7 @@ function isIos(desiredCapabilities = {}) { /** * check if target is Simulator - * @param {Object} desiredCapabilities + * @param {Object} desiredCapabilities * @returns {Boolean} */ function isSimulator(desiredCapabilities){ @@ -75,7 +75,7 @@ function isSimulator(desiredCapabilities){ /** * check if target is Real iOS Device - * @param {Object} desiredCapabilities + * @param {Object} desiredCapabilities * @returns {Boolean} */ function isRealIos(desiredCapabilities) { @@ -88,7 +88,7 @@ function isRealIos(desiredCapabilities) { /** * check if the target is a mobile platform - * @param {Object} desiredCapabilities + * @param {Object} desiredCapabilities * @returns {Boolean} */ function isMobile(desiredCapabilities){ @@ -101,14 +101,14 @@ function isMobile(desiredCapabilities){ /** * Check if Real iOS device UDID is correct - * @param {String} udid + * @param {String} udid * @returns {String} */ function iosRealDeviceUDID(udid){ if (udid.length > 25) { return udid; - } - + } + if (udid.length < 24) { throw new Error('Incorrect UDID provided for real iOS device'); } @@ -117,7 +117,7 @@ function iosRealDeviceUDID(udid){ }; /** - * Function to kill iOS Simulator + * Function to kill iOS Simulator * @param {String} udid */ function killSimulator(udid) { @@ -233,7 +233,7 @@ class AndroidConnectionError extends Error { help = [ `${Logger.colors.cyan('adb')} binary not found. Run command ${Logger.colors.cyan('npx @nightwatch/mobile-helper android')} to setup the missing requirements.` ]; - } else { + } else { if (binaryLocation === 'PATH') { binaryLocation = 'adb'; } @@ -287,7 +287,7 @@ class IosSessionNotCreatedError extends Error { `If it doesn't work, try running: ${Logger.colors.cyan('npx run @nightwatch/mobile-helper ios')}` ]; } else { - help= [ + help = [ `Make sure you have passed correct ${Logger.colors.green('deviceId')} in the command (for e.g : ${Logger.colors.cyan('--deviceId 00008030-00024C2C3453402E')})`, `Or pass ${Logger.colors.green('safari:deviceUDID')} capability in config`, `To verify the deviceId run, ${Logger.colors.cyan('system_profiler SPUSBDataType | sed -n \'/iPhone/,/Serial/p\' | grep \'Serial Number:\' | awk -F \': \' \'{print $2}')}`, diff --git a/lib/utils/printVersionInfo.js b/lib/utils/printVersionInfo.js index 44b5c33368..0322f67a5a 100644 --- a/lib/utils/printVersionInfo.js +++ b/lib/utils/printVersionInfo.js @@ -8,4 +8,4 @@ module.exports = function() { console.log(' version: ' + VERSION.full); // eslint-disable-next-line no-console console.log(' changelog: https://github.com/nightwatchjs/nightwatch/releases/tag/v' + VERSION.full + '\n'); -}; \ No newline at end of file +}; diff --git a/lib/utils/safeStringify.js b/lib/utils/safeStringify.js index 7d19ff2e19..86a33b6007 100644 --- a/lib/utils/safeStringify.js +++ b/lib/utils/safeStringify.js @@ -28,17 +28,17 @@ class SafeStringify { const result = Object.keys(obj).reduce((result, prop) => { result[prop] = this.visit(obj[prop], seen); - + return result; }, {}); seen.pop(); - + return result; } static safeJSON(obj) { - const seen = []; - + const seen = []; + return this.visit(obj, seen); } @@ -47,4 +47,4 @@ class SafeStringify { } } -module.exports = SafeStringify; \ No newline at end of file +module.exports = SafeStringify; diff --git a/lib/utils/stackTrace.js b/lib/utils/stackTrace.js index b257c1e218..ba60877744 100644 --- a/lib/utils/stackTrace.js +++ b/lib/utils/stackTrace.js @@ -116,4 +116,4 @@ module.exports = { filterStack, filterStackTrace, showStackTrace -}; \ No newline at end of file +}; diff --git a/lib/utils/timed-callback.js b/lib/utils/timed-callback.js index 084094613a..2d9fe34586 100644 --- a/lib/utils/timed-callback.js +++ b/lib/utils/timed-callback.js @@ -49,7 +49,7 @@ class TimedCallback { createTimeout() { this.timeoutId = setTimeout(() => { - let err = new TimeoutError(`done() callback timeout of ${this.timeoutMs}ms was reached while executing "${this.name}".` + + const err = new TimeoutError(`done() callback timeout of ${this.timeoutMs}ms was reached while executing "${this.name}".` + ' Make sure to call the done() callback when the operation finishes.'); this.onTimeoutExpired(err, this.name, this.timeoutMs); }, this.timeoutMs); @@ -58,4 +58,4 @@ class TimedCallback { } } -module.exports = TimedCallback; \ No newline at end of file +module.exports = TimedCallback; diff --git a/lib/utils/version.js b/lib/utils/version.js index 7641f27ba0..7c7bf9e384 100644 --- a/lib/utils/version.js +++ b/lib/utils/version.js @@ -6,4 +6,4 @@ module.exports = { major: fullVersion.split('.')[0], minor: fullVersion.split('.')[1], patch: fullVersion.split('.').slice(2).join('.') -}; \ No newline at end of file +}; diff --git a/test/extra/pageobjects/commands/workingCommandsClass.js b/test/extra/pageobjects/commands/workingCommandsClass.js index a0074cc355..cd12a7e53b 100644 --- a/test/extra/pageobjects/commands/workingCommandsClass.js +++ b/test/extra/pageobjects/commands/workingCommandsClass.js @@ -5,7 +5,7 @@ module.exports = class RealCommands { selector, suppressNotFoundErrors: true }, function(result) { - return callback(result ? result.value: []); + return callback(result ? result.value : []); }); } diff --git a/test/lib/command-mocks.js b/test/lib/command-mocks.js index 8c08da65b3..4f79dcc93a 100644 --- a/test/lib/command-mocks.js +++ b/test/lib/command-mocks.js @@ -269,7 +269,7 @@ module.exports = { }, true); }, - w3cSelected(elementId ='5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) { + w3cSelected(elementId = '5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) { MockServer.addMock({ url: `/session/13521-10219-202/element/${elementId}/selected`, method: 'GET', @@ -279,7 +279,7 @@ module.exports = { }, true); }, - w3cEnabled(elementId ='5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) { + w3cEnabled(elementId = '5cc459b8-36a8-3042-8b4a-258883ea642b', value = true) { MockServer.addMock({ url: `/session/13521-10219-202/element/${elementId}/enabled`, method: 'GET', diff --git a/test/lib/nightwatch.js b/test/lib/nightwatch.js index db72dfc1a7..85d8e218ee 100644 --- a/test/lib/nightwatch.js +++ b/test/lib/nightwatch.js @@ -46,7 +46,7 @@ module.exports = new function () { } this.createClient = function(options = {}, reporter = null, argv = {}) { - let opts = { + const opts = { selenium: { port: 10195, host: 'localhost', @@ -118,7 +118,7 @@ module.exports = new function () { }); }; - this.initW3CClient = function(opts = {}, argv={}) { + this.initW3CClient = function(opts = {}, argv = {}) { const settings = Object.assign({ selenium: { version2: false, diff --git a/test/lib/nocks.js b/test/lib/nocks.js index e40d4f5195..34820bf6e3 100644 --- a/test/lib/nocks.js +++ b/test/lib/nocks.js @@ -191,7 +191,7 @@ module.exports = { return this; }, - childElementsNotFound(selector='#badElement') { + childElementsNotFound(selector = '#badElement') { nock('http://localhost:10195') .post('/wd/hub/session/1352110219202/element/0/elements', {'using': 'css selector', 'value': selector}) .reply(200, { @@ -203,14 +203,14 @@ module.exports = { return this; }, - childElementsFound(selector='#weblogin') { + childElementsFound(selector = '#weblogin') { nock('http://localhost:10195') .post('/wd/hub/session/1352110219202/element/0/elements', {'using': 'css selector', 'value': selector}) .reply(200, { status: 0, state: 'success', value: [{'element-6066-11e4-a52e-4f735466cecf': '0'}] - }) + }); return this; }, @@ -589,7 +589,7 @@ module.exports = { .reply(200, { status: 0, state: 'success', - value : { + value: { domain: 'cookie-domain', name: name, value: value diff --git a/test/src/analytics/testAnalytics.js b/test/src/analytics/testAnalytics.js index 3b26f5c617..fa5d869f6f 100644 --- a/test/src/analytics/testAnalytics.js +++ b/test/src/analytics/testAnalytics.js @@ -173,7 +173,7 @@ describe('test analytics utility', function() { const analyticsNock = Nocks.analyticsCollector(analytics.__getGoogleAnalyticsPath()); const err = new Error('test'); - err.name ='UserGeneratedError'; + err.name = 'UserGeneratedError'; await analytics.collectErrorEvent(err); diff --git a/test/src/api/commands/client/testWaitUntil.js b/test/src/api/commands/client/testWaitUntil.js index d04108b2ad..f0873298a4 100644 --- a/test/src/api/commands/client/testWaitUntil.js +++ b/test/src/api/commands/client/testWaitUntil.js @@ -105,7 +105,7 @@ describe('.waitUntil()', function () { it('client.waitUntil() function failure with custom timeout', function (done) { let tries = 0; - let startTime = new Date().valueOf(); + const startTime = new Date().valueOf(); let timeDiff; const maxTimeout = 100; const client = this.client.api; @@ -123,7 +123,7 @@ describe('.waitUntil()', function () { this.client.start(err => { try { - assert.ok(timeDiff <= maxTimeout+100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); + assert.ok(timeDiff <= maxTimeout + 100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); assert.strictEqual(result.status, -1); assert.strictEqual(tries, 3); assert.ok(err instanceof Error); @@ -136,7 +136,7 @@ describe('.waitUntil()', function () { it('client.waitUntil() function failure with custom timeout, interval, message, and callback', function (done) { let tries = 0; - let startTime = new Date().valueOf(); + const startTime = new Date().valueOf(); let timeDiff; const maxTimeout = 100; const client = this.client.api; @@ -154,7 +154,7 @@ describe('.waitUntil()', function () { this.client.start(err => { try { - assert.ok(timeDiff <= maxTimeout+100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); + assert.ok(timeDiff <= maxTimeout + 100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); assert.strictEqual(result.status, -1); assert.ok(err instanceof Error); const messageParts = err.message.split('\n'); @@ -196,7 +196,7 @@ describe('.waitUntil()', function () { it('client.waitUntil() function failure with custom timeout and default interval', function (done) { let tries = 0; - let startTime = new Date().valueOf(); + const startTime = new Date().valueOf(); let timeDiff; const maxTimeout = 100; const client = this.client.api; @@ -215,7 +215,7 @@ describe('.waitUntil()', function () { this.client.start(err => { try { assert.ok(err instanceof Error); - assert.ok(timeDiff <= maxTimeout+100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); + assert.ok(timeDiff <= maxTimeout + 100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); assert.strictEqual(result.status, -1); assert.strictEqual(tries, 3); done(); @@ -255,7 +255,7 @@ describe('.waitUntil()', function () { it('client.waitUntil() function failure with custom waitForConditionPollInterval', function (done) { let tries = 0; - let startTime = new Date().valueOf(); + const startTime = new Date().valueOf(); let timeDiff; const maxTimeout = 100; const client = this.client.api; @@ -276,7 +276,7 @@ describe('.waitUntil()', function () { this.client.start(err => { try { assert.ok(err instanceof Error); - assert.ok(timeDiff <= maxTimeout+100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); + assert.ok(timeDiff <= maxTimeout + 100, `Expected lower than ${maxTimeout}, but got ${timeDiff}`); assert.strictEqual(result.status, -1); assert.ok(tries > 5); done(); diff --git a/test/src/api/commands/element/testWaitForElementPresent.js b/test/src/api/commands/element/testWaitForElementPresent.js index 0b5b031388..c1d80f88b1 100644 --- a/test/src/api/commands/element/testWaitForElementPresent.js +++ b/test/src/api/commands/element/testWaitForElementPresent.js @@ -55,7 +55,7 @@ describe('waitForElementPresent', function() { }); it('client.waitForElementPresent() failure with custom time message', function(done){ - this.client.api.globals.waitForConditionPollInterval=10; + this.client.api.globals.waitForConditionPollInterval = 10; this.client.api.waitForElementPresent('.weblogin', 15, function callback(result, instance){ assert.strictEqual(instance.message, 'Element .weblogin found in 15 milliseconds'); }, 'Element %s found in %d milliseconds'); diff --git a/test/src/cli/testParallelExecution.js b/test/src/cli/testParallelExecution.js index a4b899a093..7039476279 100644 --- a/test/src/cli/testParallelExecution.js +++ b/test/src/cli/testParallelExecution.js @@ -7,7 +7,7 @@ const Nightwatch = require('../../lib/nightwatch.js'); describe('test Parallel Execution', function() { const workerPoolArgv = []; - const taskArgv= []; + const taskArgv = []; const allArgs = []; const allOpts = []; @@ -88,9 +88,9 @@ describe('test Parallel Execution', function() { it('testParallelExecution - child-process', function() { const CliRunner = common.require('runner/cli/cli.js'); - let originalCwd = process.cwd(); + const originalCwd = process.cwd(); process.chdir(path.join(__dirname, '../../extra/')); - let runner = new CliRunner({ + const runner = new CliRunner({ config: './nightwatch.json', env: 'default,mixed', reporter: 'junit' @@ -167,7 +167,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers defaults -- worker thread', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism.json') }); @@ -187,10 +187,10 @@ describe('test Parallel Execution', function() { }); it('testParallelExecutionSameEnv - child-process', function() { - let originalCwd = process.cwd(); + const originalCwd = process.cwd(); process.chdir(path.join(__dirname, '../../extra/')); const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ config: './nightwatch.json', reporter: 'junit', env: 'mixed,mixed' @@ -211,11 +211,11 @@ describe('test Parallel Execution', function() { }); it('testParallelExecutionSameEnv - worker threads', function() { - let originalCwd = process.cwd(); + const originalCwd = process.cwd(); process.chdir(path.join(__dirname, '../../extra/')); const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ config: './nightwatch.json', reporter: 'junit', env: 'mixed,mixed' @@ -279,7 +279,7 @@ describe('test Parallel Execution', function() { it('testParallelExecutionWithWorkers and multiple environments - child process', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-auto.json'), env: 'default,default' @@ -294,7 +294,7 @@ describe('test Parallel Execution', function() { it('testParallelExecutionWithWorkers and multiple environments - worker threads', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-auto.json'), env: 'default,default' @@ -310,7 +310,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers count - child process', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-count.json') }); @@ -329,7 +329,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers count - worker threads', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-count.json') }); @@ -349,7 +349,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers=count arg', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-count.json'), workers: 2 @@ -364,7 +364,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers count and extended envs', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-workers.conf.js'), env: 'chrome' @@ -382,7 +382,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers disabled per environment', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism-disabled.json') }); @@ -394,7 +394,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers and single source file', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism.json'), _source: [path.join(__dirname, '../../../sampletests/async/test/sample.js')] @@ -408,7 +408,7 @@ describe('test Parallel Execution', function() { it('test parallel execution with workers and single source folder', function() { const CliRunner = common.require('runner/cli/cli.js'); - let runner = new CliRunner({ + const runner = new CliRunner({ reporter: 'junit', config: path.join(__dirname, '../../extra/parallelism.json'), _source: path.join(__dirname, '../../../sampletests/before-after') diff --git a/test/src/runner/cli/testCliRunnerParallel.js b/test/src/runner/cli/testCliRunnerParallel.js index 31e45a4252..13ecb1dde7 100644 --- a/test/src/runner/cli/testCliRunnerParallel.js +++ b/test/src/runner/cli/testCliRunnerParallel.js @@ -126,7 +126,7 @@ describe('Test CLI Runner in Parallel', function () { setTimeout(()=>{ numberOfTasks++; reject(new Error('Nigtwatch custom error')); - }, 10*(numberOfTasks+1)); + }, 10 * (numberOfTasks + 1)); })); return Promise.resolve(0); diff --git a/test/src/runner/cucumber-integration/testCliArgs.js b/test/src/runner/cucumber-integration/testCliArgs.js index c87ca2e4db..cf16847624 100644 --- a/test/src/runner/cucumber-integration/testCliArgs.js +++ b/test/src/runner/cucumber-integration/testCliArgs.js @@ -42,7 +42,7 @@ describe('Cucumber cli arguments', function(){ let index = cliArgs.indexOf('--require-module') + 1; assert.strictEqual(cliArgs[index], 'coffeescript/register'); - index = cliArgs.indexOf('--require-module', index)+1; + index = cliArgs.indexOf('--require-module', index) + 1; assert.strictEqual(cliArgs[index], 'ts-node/register'); }); @@ -59,17 +59,17 @@ describe('Cucumber cli arguments', function(){ assert.strictEqual(cliArgs.length, 21); assert.ok(cliArgs.includes('--name')); - assert.strictEqual(cliArgs[cliArgs.indexOf('--name')+1], 'sample'); + assert.strictEqual(cliArgs[cliArgs.indexOf('--name') + 1], 'sample'); assert.ok(cliArgs.includes('--fail-fast')); assert.ok(cliArgs.includes('--retry')); - assert.strictEqual(cliArgs[cliArgs.indexOf('--retry')+1], 2); + assert.strictEqual(cliArgs[cliArgs.indexOf('--retry') + 1], 2); assert.ok(cliArgs.includes('--retry-tag-filter')); - assert.strictEqual(cliArgs[cliArgs.indexOf('--retry-tag-filter')+1], '@nightwatch'); + assert.strictEqual(cliArgs[cliArgs.indexOf('--retry-tag-filter') + 1], '@nightwatch'); assert.ok(cliArgs.includes('--profile')); - assert.strictEqual(cliArgs[cliArgs.indexOf('--profile')+1], 'local'); + assert.strictEqual(cliArgs[cliArgs.indexOf('--profile') + 1], 'local'); assert.ok(cliArgs.includes('--no-strict')); assert.ok(cliArgs.includes('--parallel')); - assert.strictEqual(cliArgs[cliArgs.indexOf('--parallel')+1], 3); + assert.strictEqual(cliArgs[cliArgs.indexOf('--parallel') + 1], 3); assert.ok(cliArgs.includes('--require')); }); @@ -127,8 +127,8 @@ describe('Cucumber cli arguments', function(){ assert.ok(cliArgs.includes('--retry')); assert.ok(cliArgs.includes('--format')); - assert.strictEqual(cliArgs[cliArgs.indexOf('--retry')+1], 3); - assert.strictEqual(cliArgs[cliArgs.indexOf('--format')+1], '@cucumber/pretty-formatter'); + assert.strictEqual(cliArgs[cliArgs.indexOf('--retry') + 1], 3); + assert.strictEqual(cliArgs[cliArgs.indexOf('--format') + 1], '@cucumber/pretty-formatter'); }); it('Cucumber cli arg --enable-esm', function(){