happo / happo.io

Happo is a cross-browser screenshot testing service
https://happo.io
MIT License
196 stars 25 forks source link

Possibility to replace config parameters in CLI with CLI args #54

Open jack-sf opened 5 years ago

jack-sf commented 5 years ago

For example, even if my .happo.js includes


  targets: {
    'chrome-desktop': new RemoteBrowserTarget('chrome', {
      viewport: '1200x768',
    }),
    // 'chrome-mobile': new RemoteBrowserTarget('chrome', {
    //   viewport: '320x640',
    // }),
    // 'safari-desktop': new RemoteBrowserTarget('safari', {
    //   viewport: '1200x768',
    // }),
    'safari-mobile': new RemoteBrowserTarget('safari', {
      viewport: '320x640',
    }),
    ie11: new RemoteBrowserTarget('internet explorer', {
      viewport: '1200x768',
    }),
    // Happo currently throws error 500 for ios-safari builds
    // TODO turn it back on when Happo team fixes it
    // iphone: new RemoteBrowserTarget('ios-safari', {
    //   viewport: '375x667',
    // }),
  },

if I could do happo run --targets ie11 or happo dev --targets safari-mobile , I could limit the targets to be enabled on this run only to the specified targets.

(Similarly as --only xxx works in happo dev mode.)

trotzig commented 5 years ago

This would be a nice addition, thanks for suggesting it!

I can't make any promises to when we'll get to this, so I'd be very happy to accept a PR! I think the easiest way would be to start at src/executeCli.js, add another commander option (--targets?), pass that value to loadUserConfig and have it filter out the right targets.

trotzig commented 5 years ago

...and sorry about the instability of ios-safari. I'm working on that, I hope to have an update for you soon!

jack-sf commented 5 years ago

Would a --target be a better name?

trotzig commented 5 years ago

That would work too. I don't feel strongly about it, as long as you're able to specify one or more targets. Either --targets ie,chrome or --target chrome --target ie, I'm okay with both.