title: Running Tests in Parallel in Night watch
body: <p>Need some help in figuring out how to run tests in parallel.
  Here is how the project is configured and the command I use to run a test.</p>
  
  <p>On the terminal window in run the command - 'npm run test-qa' whoch actually call the 'package.json' which has a script tag to called 'test-qa'. 
  Here is how my package.json looks like:</p>
  
  <pre><code>{
    "name": "Project",
    "version": "2.0.0",
    "dependencies": {
      "babel-core": "^6.8.0",
      "babel-eslint": "^7.2.3",
      "babel-loader": "^7.1.2",
      "babel-polyfill": "^6.8.0",
      "babel-preset-es2015": "^6.6.0",
      "babel-preset-react": "^6.5.0",
      "babel-preset-react-hmre": "^1.1.1",
      "babel-preset-stage-0": "^6.5.0",
      "babel-register": "^6.26.0",
      "eslint-loader": "^1.9.0",
      "gulp": "^3.9.1",
      "gulp-eslint": "^4.0.0",
      "gulp-nightwatch": "^0.2.6",
      "handlebars": "^4.0.10",
      "json-parser": "^1.1.5",
      "json-stringify": "^1.0.0",
      "oracledb": "^1.13.1",
      "webpack-nightwatch-plugin": "^1.0.0"
    },
    "scripts": {
      "test-local": "eslint . &amp;&amp; gulp local:e2e --compilers js:babel-core/register --require babel-polyfill",
      "test-dev": "eslint . &amp;&amp; gulp dev:e2e --compilers js:babel-core/register --require babel-polyfill",
      ***"test-qa": "eslint . &amp;&amp; gulp qa:e2e --compilers js:babel-core/register --require babel-polyfill --env local",***
    },
    "devDependencies": {
      "gulp": "^3.9.1",
      "moment-timezone": "^0.5.20",
      "selenium-server-standalone-jar": "2.47.1"
    }
  }
  </code></pre>
  
  <p>The test-qa tag from package.json, in turn, calls gulpfile.js to execute the actual task(qa:e2e) in this case. Here is my gulp file code :</p>
  
  <pre><code>const gulp = require('gulp');
  const nightwatch = require('gulp-nightwatch');
  
  const eslint = require('gulp-eslint');
  
  gulp.task('qa:e2e', function qaSpec() {
      process.env.seleniumon = 'qa';
      return gulp.src('')
          .pipe(nightwatch({
              configFile: 'nightwatch.json',
              cliArgs: ['--env local', '--reporter html-reporter.js']
          }));
  });
  
  gulp.task('local:e2e', function localSpec() {
      process.env.seleniumon = 'local';
      return gulp.src('')
          .pipe(nightwatch({
              configFile: 'nightwatch.json',
              cliArgs: ['--env local', '', '--reporter html-reporter.js']
          }));
  });
  
  gulp.task('dev:e2e', function devSpec() {
      process.env.seleniumon = 'dev';
      return gulp.src('')
          .pipe(nightwatch({
              configFile: 'nightwatch.json',
              cliArgs: ['--env local', '--reporter html-reporter.js']
          }));
  });
  
  gulp.task('lint', function srcSpec() {
      return gulp.src(['**/*.js', '!node_modules/**'])
          .pipe(eslint())
          .pipe(eslint.format())
          .pipe(eslint.failAfterError());
  });
  
  gulp.task('default', ['lint']);
  </code></pre>
  
  <p>the qa:e2e task from gulpfile.js now calls nightwatch.json file to get settings and continue with the execution. Here is my nightwatch.json file:</p>
  
  <pre><code>{
    "src_folders": ["tests"],
    "output_folder": "reports",
    "custom_commands_path": [ "commons/util", "commons/up", "commons/searchPane", "commons/EditorValidations", "commons/model"],
    "custom_assertions_path": "",
    "page_objects_path": ["pages/admin", "pages/UP", "pages/searchPane", "pages/EditorValidations/CMO", "pages/EditorValidations/CPO", "pages/EditorValidations/GMO", "pages/EditorValidations/GPO", "pages/model"],
    "globals_path": "",
  
    "selenium" : {
      "start_process" : true,
      "server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-2.47.1.jar",
      "host" : "127.0.0.1",
      "port" : 4444,
      "cli_args" : {
        "webdriver.chrome.driver" : "drivers/chromedriver",
        "webdriver.ie.driver" : ""
      }
    },
  
    "test_settings": {
      "chrome": {
        "selenium_port": 4444,
        "selenium_host": "selenium-hub.nikedev.com",
        "skip_testcases_on_fail": true,
        "end_session_on_fail":false,
        "globals": {
          "platform": "desktop"
        },
        "screenshots": {
          "enabled": true,
          "on_failure": true,
          "on_error": true,
          "path": "screenshots/chrome"
        },
        "desiredCapabilities": {
          "browserName": "chrome",
          "javascriptEnabled": true,
          "acceptSslCerts": true
        }
      },
      "local": {
        "selenium_port": 4444,
        "selenium_host": "127.0.0.1",
        "skip_testcases_on_fail": true,
        "end_session_on_fail":false,
        "globals": {
          "platform": "desktop"
        },
        "screenshots": {
          "enabled": true,
          "on_failure": true,
          "on_error": true,
          "path": "screenshots/chrome"
        },
        "desiredCapabilities": {
          "browserName": "chrome",
          "javascriptEnabled": true,
          "acceptSslCerts": true
        }
      }
    }
  }
  </code></pre>
  
  <p>This setup is able to execute seamlessly.
  I wanted to run test cases parallel and for the I added the following line to my nightwatch.json after "global_path"
    "test_workers" : {"enabled" : true, "workers" : "auto"},</p>
  
  <p>After this configuration change the tests never initiated with an error ' throw new Error('Invalid testing environment specified: ' + envs[i]);' even though my gulp file has mention for the environment we want it to run. 
  cliArgs: ['--env local', '--reporter html-reporter.js']</p>
  
  <p>Can someone help me understand what changes do I need to make to run the test cases parallel?</p>