teerapap / grunt-protractor-runner

A Grunt plugin for running protractor runner.
MIT License
149 stars 123 forks source link

Boolean properties in params are always true #130

Closed spinningarrow closed 8 years ago

spinningarrow commented 9 years ago

I have a grunt config that sets the params property like this:

options: {
  configFile: 'path/to/conf.js',
  args: {
    params: {
      someKey: 'someValue',
      otherKey: true,
      thirdKey: false
    }
  }
}

But when I log the values (in the onPrepare function in my config file, don't think that matters) like this:

console.log(browser.params.someKey, browser.params.otherKey, browser.params.thirdKey)

I get the result

someValue, true, true

Any idea what's going on?

spinningarrow commented 9 years ago

I added a failing test to demonstrate this behaviour here: https://github.com/spinningarrow/grunt-protractor-runner/commit/be1377e07df81c6506dacf354c5861921bd6dea3

spinningarrow commented 9 years ago

I did some more digging. According to this comment on StackOverflow, it seems like this is going to be difficult to support since the params are passed in using command line flags which only support string values.

UPDATE: One solution would be to check if the value of the boolean is true and only then include the argument. However, this means that if the value is false, when accessed in browser.params it will become undefined, which I'm sure will be cause for surprise.

What do you say regarding not supporting Boolean values (similar to functions and null) and making a note of this in the readme?

chrismikehogan commented 9 years ago

+1

teerapap commented 8 years ago

Sorry for taking a long time. Fixed in v2.1.2