使用Nightwatch和Browserstack通过test_workers进行线程测试

时间:2018-02-19 18:53:49

标签: nightwatch.js browserstack

在Browserstack上运行时是否可以并行运行nightwatch测试套件?我注意到Nightwatch + Browserstack文档的这一部分说明你应该将它设置为false。通过这个,他们基本上说这是不可能的吗? https://www.browserstack.com/automate/nightwatch-integration#running-first-test

希望将此添加到我的Nightwatch配置(在本地工作正常 - 没有Browserstack)

test_workers: {
  enabled: true,
  workers: 'auto',
},

1 个答案:

答案 0 :(得分:1)

是的,您当然可以在BrowserStack上运行并行测试。这是一个工作配置文件,我一直用它来使用Nightwatch在BrowserStack上并行测试

nightwatch_config = {
  src_folders : [ "tests/suite" ],

  selenium : {
    "start_process" : false,
    "host" : "hub-cloud.browserstack.com",
    "port" : 80
  },

  test_settings: {
    default: {
      desiredCapabilities: {
        'build': 'nightwatch-browserstack',
        'browserstack.user': process.env.BROWSERSTACK_USERNAME || 'BROWSERSTACK_USERNAME',
        'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY || 'BROWSERSTACK_ACCESS_KEY',
        'browserstack.debug': true,
        'browser': 'chrome'
      }
    }
  },

  "test_workers": {
    "enabled": true,
    "workers": 10
  }   
};

// Code to copy seleniumhost/port into test settings
for(var i in nightwatch_config.test_settings){
  var config = nightwatch_config.test_settings[i];
  config['selenium_host'] = nightwatch_config.selenium.host;
  config['selenium_port'] = nightwatch_config.selenium.port;
}

module.exports = nightwatch_config;