Skip to content

Commit

Permalink
Merge branch 'main' into harshit-bs/3706
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityvi committed Sep 22, 2023
2 parents 12b3cfe + 17a5d7b commit 1fb8512
Show file tree
Hide file tree
Showing 236 changed files with 3,982 additions and 2,333 deletions.
35 changes: 32 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"root": true,
"extends": [
"eslint:recommended"
],
"parserOptions": {
"ecmaVersion": 2020,
"ecmaVersion": 13,
"sourceType": "module",
"ecmaFeatures": {
"jsx": false
Expand All @@ -13,6 +14,33 @@
"mocha": true,
"node": true
},
"overrides": [
{
"files": [
"**/*.ts"
],
"excludedFiles": [
"test/**/*.ts"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": false
},
"project": "./tsconfig.json"
}
}
],
"rules": {
"eqeqeq": [
"error",
Expand Down Expand Up @@ -43,13 +71,13 @@
"omitLastInOneLineBlock": true
}
],
"no-trailing-spaces": 0,
"no-trailing-spaces": 1,
"no-else-return": 2,
"no-extra-bind": 0,
"no-implicit-coercion": 0,
"no-useless-call": 0,
"no-return-assign": 0,
"eol-last": 0,
"eol-last": 1,
"no-unused-vars": 0,
"no-extra-semi": 0,
"comma-dangle": 2,
Expand Down Expand Up @@ -86,6 +114,7 @@
"after": true
}
],
"space-infix-ops": 1,
"padding-line-between-statements": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
4 changes: 2 additions & 2 deletions api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -29,4 +29,4 @@ const props = exportedCommands.reduce((prev, fileName) => {

Object.defineProperties(Commands, props);

module.exports = Commands;
module.exports = Commands;
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Then(/^the title is "([^"]*)"$/, function(title) {

Then(/^Body contains "([^"]*)"$/, function(contains) {
return browser.assert.textContains('.search-results', contains);
});
});
2 changes: 1 addition & 1 deletion examples/custom-commands/strictClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module.exports = {
return this.waitForElementVisible(selector)
.click(selector);
}
};
};
2 changes: 1 addition & 1 deletion examples/pages/google/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const searchCommands = {
submit() {
this.waitForElementVisible('@submitButton', 1000)
.click('@submitButton');

this.pause(1000);

return this; // Return page object for chaining
Expand Down
4 changes: 2 additions & 2 deletions examples/pages/google/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
Expand Down Expand Up @@ -44,4 +44,4 @@ module.exports = {
}
}
}
};
};
4 changes: 2 additions & 2 deletions examples/tests/chromeCDP_example.js
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -11,4 +11,4 @@ describe('Chrome DevTools Example', function() {

browser.assert.deepStrictEqual(Object.keys(dom), ['documents', 'strings']);
});
});
});
2 changes: 1 addition & 1 deletion examples/tests/duckDuckGo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ describe('duckduckgo example', function() {
.assert.visible('button[type=submit]')
.click('button[type=submit]')
.assert.textContains('.react-results--main', 'Nightwatch.js');
});
});
});
2 changes: 1 addition & 1 deletion examples/tests/element/elementapi-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ describe('queries tests', function() {
});


});
});
2 changes: 1 addition & 1 deletion examples/tests/sample-with-relative-locators.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ describe('sample with relative locators', function () {
});

after(browser => browser.end());
});
});
2 changes: 1 addition & 1 deletion examples/tests/selectElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ module.exports = {
})
.assert.selected(await selectElement.findElement('option[value=four]'), 'Forth option is selected');
}
};
};
2 changes: 1 addition & 1 deletion examples/tests/shadowRootExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ describe('Shadow Root example test', function() {
// await expect.element(firstElement).to.be.an('img');

});
});
});
2 changes: 1 addition & 1 deletion examples/unittests/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ module.exports = {
assert.strictEqual(Utils.getTestSuiteName('test.case.one'), 'Test Case One');
assert.strictEqual(Utils.getTestSuiteName('testCaseOne'), 'Test Case One');
}
};
};
2 changes: 1 addition & 1 deletion examples/unittests/testUtilsWithChai.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ module.exports = {
var resultMs = Utils.formatElapsedTime(999);
expect(resultMs).to.equal('999ms');
}
};
};
10 changes: 5 additions & 5 deletions lib/api/_loaders/_base-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
14 changes: 7 additions & 7 deletions lib/api/_loaders/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -74,8 +74,8 @@ class CommandLoader extends BaseCommandLoader {
reportProtocolErrors(result) {
if (opts.isUserDefined) {
return true;
}
}

return super.reportProtocolErrors(result);
}

Expand All @@ -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
);
}

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions lib/api/_loaders/element-global.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ElementGlobal {
value = {
value: locator,
using: this.client.locateStrategy
};
};
} else {
value = locator;
}
Expand Down Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion lib/api/_loaders/expect.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ExpectLoader extends BaseCommandLoader {
deferred.reject(err);
});
}

return expectCommand.instance;
}.bind(this));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/api/_loaders/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/_assertionInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions lib/api/assertions/domPropertyMatches.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 || '';
Expand Down
2 changes: 1 addition & 1 deletion lib/api/assertions/elementsCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports.assertion = function (definition, count, msg) {


this.command = async function(callback) {

await this.api.findElements(definition, callback);
};
};
4 changes: 2 additions & 2 deletions lib/api/assertions/enabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -43,5 +43,5 @@ exports.assertion = function(definition, msg) {
this.command = function(callback) {
this.api.isEnabled(definition, callback);
};

};

0 comments on commit 1fb8512

Please sign in to comment.