beatfactor/nightwatch — pull request #166 by beo31 (2014-05-23 13:18:11+00:00)
Title: Adding handling for globals commonly used in all environments

Hi there,

since we have several environments that share many variables (e.g. for locators) but differ in other (e.g. base urls), we were searching for a solution to define common variables that are loaded regardless of the environment. Also you are required to specify all variables used in your testcases for each environment, there is no fallback/default. Any global value from the configuration gets replaced by the values from the globals file.

To solve these issues, I introduced a concept and handling for common variables to the runner.js and added a configuration parameter to control its use:
- new parameter: "globals_common_env" - its value is the name of the "environment" used for storing common parameters in the globals file, e.g. "common"; if you don't specify one, the old logic will be used.
- function "addGlobals" in runner.js handling the common variables

You can add any common variables you want to use for all environments to the "common" env config in the globals.json file then.

There exists an order for globals now, in which the values get overwritten:
1) global from configuration, i.e. nightwatch.json, gets overwritten by
2) global from "common" in globals.json, gets overwritten by
3) global from env in globals.json

I did not test with .js globals, though...

Also, I am a first time github user and first time javascript developer, so be kind your critics. ;-)

Cheers,
Thorsten