From 7e51dc5968a523c6105dc8c4592cfb75189faa0b Mon Sep 17 00:00:00 2001
From: Andrei Rusu <andrei.rusu@beatfactor.net>
Date: Sun, 23 Jan 2022 16:14:30 +0100
Subject: [PATCH] Added --debug cli flag and default http retries for
 connection errors

---
 lib/runner/cli/argv-setup.js  | 7 ++++++-
 lib/settings/defaults.js      | 6 +++---
 test/src/cli/testCliRunner.js | 6 +++++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/lib/runner/cli/argv-setup.js b/lib/runner/cli/argv-setup.js
index d58a87c930..b7298fba74 100644
--- a/lib/runner/cli/argv-setup.js
+++ b/lib/runner/cli/argv-setup.js
@@ -400,7 +400,12 @@ module.exports = new (function () {
 
       // $ nightwatch --devtools
       this.option('devtools', {
-        description: 'Automatically open devtools when launching the browser (Chrome or Edge)'
+        description: 'Automatically open devtools when launching the browser (Chrome or Edge).'
+      });
+
+      // $ nightwatch --debug
+      this.option('debug', {
+        description: 'When --devtools is on, this flag can be used to automatically pause the test execution.'
       });
 
       // $ nightwatch --verbose
diff --git a/lib/settings/defaults.js b/lib/settings/defaults.js
index aef4da2d3c..cfc3ee302c 100644
--- a/lib/settings/defaults.js
+++ b/lib/settings/defaults.js
@@ -181,7 +181,6 @@ module.exports = {
     // leave empty to use the test suite name when writing the webdriver server logs
     log_file_name: '',
 
-
     // Time to wait (in ms) before starting to check the Webdriver server is up and running
     check_process_delay: 100,
 
@@ -193,13 +192,14 @@ module.exports = {
 
     // The entire time (in ms) to wait for the Node.js process to be created and running (default is 2 min), including spawning the child process and checking the status
     process_create_timeout: 120000,
+
     host: undefined,
     port: undefined,
     ssl: undefined,
     proxy: undefined,
     timeout_options: {
-      timeout: undefined,
-      retry_attempts: undefined
+      timeout: 90000,
+      retry_attempts: 2
     },
     default_path_prefix: undefined,
     username: undefined,
diff --git a/test/src/cli/testCliRunner.js b/test/src/cli/testCliRunner.js
index b2161a99e7..f157401ae7 100644
--- a/test/src/cli/testCliRunner.js
+++ b/test/src/cli/testCliRunner.js
@@ -356,9 +356,13 @@ describe('Test CLI Runner', function() {
       tag: 'danger',
       filter: 'test-filename-filter',
       skipgroup: 'test-skip-group',
-      timeout: 11
+      timeout: 11,
+      devtools: true,
+      debug: true
     }).setup();
 
+    assert.strictEqual(runner.argv.devtools, true);
+    assert.strictEqual(runner.argv.debug, true);
     assert.strictEqual(runner.test_settings.silent, false);
     assert.strictEqual(runner.test_settings.tag_filter, 'danger');
     assert.strictEqual(runner.test_settings.skiptags, 'home,arctic');