tacoss / grunt-nightwatch

Run your Nightwatch.js tests with Grunt
50 stars 22 forks source link

How to define targets #46

Closed jansepke closed 8 years ago

jansepke commented 9 years ago

How to I override options for a specific target? I have the following in my Gruntfile:

nightwatch: {
    options: {
        standalone: true,
        src_folders: ['config/grunt/tests'],
        jar_path: '<%= path.references %>/selenium/selenium-server-standalone-2.45.0.jar',
        selenium: {
            start_process: true,
            server_path: '<%= path.references %>/selenium/selenium-server-standalone-2.45.0.jar',
            host: '127.0.0.1',
            port: 4444,
            cli_args: {
                'webdriver.chrome.driver': '<%= path.references %>/selenium/chromedriver.exe',
                'webdriver.ie.driver': '<%= path.references %>/selenium/IEDriverServer.exe'
            }
        },
        test_settings: {
            default: {
                selenium_host: '127.0.0.1',
                selenium_port: 4444,
                desiredCapabilities: {
                    browserName: 'chrome',
                    javascriptEnabled: true,
                    acceptSslCerts: true
                }
            },
            google: {
                src_folders: ['config/grunt/tests/google']
            }
        },
        google: {
            src_folders: ['config/grunt/tests/google']
        }
    },
    google: {
        src_folders: ['config/grunt/tests/google']
    }
}

if I run grunt nightwatch my 2 tests will run if I run grunt nightwatch:google also both tests run

How should I define targets to override properties?

unindented commented 9 years ago

@pateketrueke Even after looking at the conversation in the pull request, I still don't understand how to define multiple targets.

My configuration for the grunt-nightwatch task looks like this:

var optionsFor = function (options) {
  return {
    desiredCapabilities: {
      browserName: 'chrome',
      javascriptEnabled: true,
      acceptSslCerts: true,
      chromeOptions: {
        binary: 'dist/electron/' +
          '<%= package.projectName %>-' + options.platform + '-' + options.arch + '/' +
          '<%= package.projectName %>.app/Contents/MacOS/Electron'
      }
    }
  };
};

module.exports = {
  options: {
    src_folders: ['tests/integration'],
    standalone: true
  },

  darwin32: optionsFor({platform: 'darwin', arch: 'ia32'}),
  darwin64: optionsFor({platform: 'darwin', arch: 'x64'})
};

So basically I want to run the same tests with the same options, but changing the browser binary for each target.

Running grunt nightwatch:darwin32:darwin64 --verbose gives the following:

Running tasks: nightwatch:darwin32:darwin64

Running "nightwatch:darwin32:darwin64" (nightwatch) task
>> Task options
{"standalone":true,"jar_path":null,"jar_url":"http://selenium-release.storage.googleapis.com/{x}.{y}/selenium-server-standalone-{x}.{y}.{z}.jar","jar_version":"2.45.0","config_path":null}
>> Using already downloaded Selenium from .../node_modules/grunt-nightwatch/selenium-server-standalone-2.45.0.jar
>> Settings (darwin32, darwin64)
{"src_folders":["tests/integration"],"output_folder":"reports","selenium":{"start_process":true,"server_path":".../node_modules/grunt-nightwatch/selenium-server-standalone-2.45.0.jar"}}
>> Test settings
{"default":{"silent":true,"output":true}}
>> .../node_modules/grunt-nightwatch/node_modules/nightwatch/lib/runner/cli/clirunner.js:378
>> throw new Error('Invalid testing environment specified: ' + envs[i]);
>> ^
Fatal error: Cannot read property '1' of null

Why are those final test settings empty, if the settings for darwin32 and darwin64 are there?

pateketrueke commented 9 years ago

After investigating I've found this:

grunt.initConfig({
  nightwatch: {
    options: {
      test_settings: {
        a: {},
        b: {}
       }
    }
  }
});

Run grunt nightwatch:a:b to execute in parallel...

It seems to be broken to me.

Edit: please don't execute that; I've found what happened and I'm working/fixing a new release asap. :bomb:

cactusme commented 9 years ago

Any update? This causes failure when I upgrade from v0.4.6 to v0.4.8

pateketrueke commented 9 years ago

Targets were fixed on 0.5.0, please update and test.

cactusme commented 9 years ago

Verified it's good now