title: How to call the Nightwatch.runTests correctly?
body: <p>When I call the Nightwatch.runTests method from the code, I get an error:</p>
  <pre><code>/ Connecting to 127.0.0.1 on port 4444...
      POST  /wd/hub/session - ECONNREFUSED
  ‼ Error connecting to 127.0.0.1 on port 4444.
  _________________________________________________
  
     Error: An error occurred while retrieving a new session: &quot;Connection refused to 127.0.0.1:4444&quot;. If the Webdriver/Selenium service is managed by Nightwatch, check if &quot;start_process&quot; is set to &quot;true&quot;.    
         at Socket.socketErrorListener (_http_client.js:407:9)
         at emitErrorNT (internal/streams/destroy.js:84:8)
         at processTicksAndRejections (internal/process/task_queues.js:80:21)
  </code></pre>
  <p>The documentation <a href="https://nightwatchjs.org/guide/running-tests/#programmatic-api" rel="nofollow noreferrer">here</a> and <a href="https://github.com/nightwatchjs/nightwatch-docs/blob/master/guide/running-tests/programmatic-api.md" rel="nofollow noreferrer">here</a> says that the method accepts two parameters: [testSource] and [settings].
  As [testSource] I specify the path to the folder with the tests. For [settings], I specify a json object equivalent to the contents of the nightwatch.json file. As stated in the error, the parameter &quot;start_process&quot; is set to true.</p>
  <p>Here is the code to reproduce:</p>
  <pre><code>const Nightwatch = require('nightwatch');
  const seleniumServer = require('selenium-server-standalone-jar');
  const chromedriver = require('chromedriver');
  
  const settings = {
      src_folders: ['tests'],
      output_folder: 'reports',
      detailed_output: true,
      live_output: true,
      selenium: {
          start_process: false,
          &quot;server_path&quot;: seleniumServer.path,
          &quot;log_path&quot;: &quot;logs&quot;,
          &quot;host&quot;: &quot;127.0.0.1&quot;,
          &quot;port&quot;: 4444,
          &quot;cli_args&quot;: {
              &quot;trustAllSSLCertificates&quot;: true,
              &quot;webdriver.chrome.driver&quot;: chromedriver.path
          }
      },
      test_settings: {
          default: {
              silent: true,
              disable_error_log: false,
              screenshots: {
                  enabled: false,
                  path: 'screenshots',
                  on_failure: true
              },
          },
          chrome: {
              desiredCapabilities: {
                  browserName: 'chrome',
                  javascriptEnabled: true,
                  acceptSslCerts: true,
                  chromeOptions: {
                      w3c: false
                  }
              }
          }
      }
  };
  
  Nightwatch.runTests('tests', settings).then(function() {
      // Tests finished
  }).catch(function(err) {
      // An error occurred
  });
  </code></pre>
  <p>In my project I use &quot;nightwatch&quot;: &quot;^ 1.3.6&quot; and &quot;selenium-server-standalone-jar&quot;: &quot;^ 3.141.59&quot;.</p>
  <p>I also changed the settings object, in accordance with the structure of the auto-generated file &quot;nightwatch.conf.js&quot;:</p>
  <pre><code>const settings = {
      src_folders: ['tests'],
      output_folder: 'reports',
      detailed_output: true,
      live_output: true,
  
      test_settings: {
          default: {
              disable_error_log: false,
              launch_url: 'https://nightwatchjs.org',
  
              screenshots: {
                  enabled: false,
                  path: 'screens',
                  on_failure: true
              },
  
              desiredCapabilities: {
                  browserName: 'chrome'
              },
  
              webdriver: {
                  start_process: true,
                  server_path: chromedriver.path
              }
          },
  
          chrome: {
              desiredCapabilities: {
                  browserName: 'chrome',
                  chromeOptions: {
                      args: []
                  }
              },
  
              webdriver: {
                  start_process: true,
                  port: 9515,
                  server_path: chromedriver.path,
                  cli_args: []
              }
          },
  
          selenium: {
              selenium: {
                  start_process: true,
                  port: 4444,
                  server_path: seleniumServer.path,
                  cli_args: {
                      'webdriver.chrome.driver': chromedriver.path
                  }
              }
          },
  
          'selenium.chrome': {
              extends: 'selenium',
              desiredCapabilities: {
                  browserName: 'chrome',
                  chromeOptions: {
                      w3c: true
                  }
              }
          }
      }
  };
  </code></pre>
  <p>but this did not help, the error continues to arise.</p>
  <p>I would be grateful if anyone could help solve this problem.</p>