Skip to content

Commit

Permalink
Fix Too many error messages on a single failure nightwatchjs#3631
Browse files Browse the repository at this point in the history
  • Loading branch information
harshit-bs committed Apr 12, 2023
1 parent 7b621bf commit 52baf13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/api/_loaders/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ class CommandLoader extends BaseCommandLoader {

if (!['NightwatchAssertError', 'NightwatchMountError', 'TestingLibraryError'].includes(err.name)) {
Logger.error(err);
instance.client.reporter.registerTestError(err);

if (err.detailedLogging) {
instance.client.reporter.registerTestError(err);
}
}

return err;
Expand Down
16 changes: 12 additions & 4 deletions lib/api/protocol/windowPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ const ProtocolAction = require('./_base-action.js');
module.exports = class Session extends ProtocolAction {
command(windowHandle, offsetX, offsetY, callback) {
if (typeof windowHandle !== 'string') {
throw new Error('First argument must be a window handle string.');
const err = new Error('First argument must be a window handle string.');
err.detailedLogging = false;
throw err;
}

if (arguments.length <= 2) {
if (typeof arguments[1] != 'function') {
throw new Error(`Second argument passed to .windowPosition() should be a callback when not passing offsetX and offsetY - ${typeof arguments[1]} given.`);
const err = new Error(`Second argument passed to .windowPosition() should be a callback when not passing offsetX and offsetY - ${typeof arguments[1]} given.`);
err.detailedLogging = false;
throw err;
}

return this.transportActions.getWindowPosition(windowHandle, arguments[1]);
Expand All @@ -46,11 +50,15 @@ module.exports = class Session extends ProtocolAction {
offsetY = Number(offsetY);

if (typeof offsetX !== 'number' || isNaN(offsetX)) {
throw new Error('offsetX argument passed to .windowPosition() must be a number.');
const err = new Error('offsetX argument passed to .windowPosition() must be a number.');
err.detailedLogging = false;
throw err;
}

if (typeof offsetY !== 'number' || isNaN(offsetY)) {
throw new Error('offsetY argument passed to .windowPosition() must be a number.');
const err = new Error('offsetY argument passed to .windowPosition() must be a number.');
err.detailedLogging = false;
throw err;
}

return this.transportActions.setWindowPosition(offsetX, offsetY, callback);
Expand Down

0 comments on commit 52baf13

Please sign in to comment.