protractor-styleguide icon indicating copy to clipboard operation
protractor-styleguide copied to clipboard

set global variables in a file - not in conf file

Open fabbsc opened this issue 7 years ago • 3 comments

currently global variables are being set in onPrepare: function () { global.myFirstVar = 1; },

I have about 30 variables, and the conf file it's starting to get a bit messy. It would be a bit more organised if we could link the global variables directly in a file.

fabbsc avatar Mar 09 '17 13:03 fabbsc

Is this a proposal for a new rule in the style guide?

robinj avatar Mar 09 '17 15:03 robinj

Yes, it is. I am storing global variables as arrays, found a slightly better approach, but in my opinion it would result in a much clearer conf file.

Currently, I am storing value like this:

onPrepare: function () { global.priceA = { "price1": 11 }, global.priceB = { "price1": 71 };

And I have about 60 global variables, so far. My suggestion is to save all the global variables to a different file. For example, reference it.

fabbsc avatar Mar 10 '17 06:03 fabbsc

http://stackoverflow.com/questions/31532276/protractor-how-to-make-the-configuration-file-more-flexible reference as example

fabianclain avatar Mar 16 '17 12:03 fabianclain