在单个浏览器会话中运行所有webdriver.io规范文件

时间:2016-12-14 02:59:52

标签: session webdriver-io

我正在使用wdio在我的本地计算机上运行测试;我启动一台服务器并对其进行测试。我将maxInstances减少为1,这样在每次测试之前重置数据库都没有问题。

我的配置是:

exports.config = {
  specs: [
    './test/wdioTests.js',
  ],
  maxInstances: 1,
  capabilities: [{
    maxInstances: 1,
    browserName: 'phantomjs',
  }],
  sync: true,
  logLevel: 'command',
  coloredLogs: true,
  screenshotPath: './errorShots/',
  baseUrl: process.env.ROOT_URL,
  waitforTimeout: 10000,
  connectionRetryTimeout: 90000,
  connectionRetryCount: 3,
  services: [
    'phantomjs'
  ],
  framework: 'mocha',
  reporters: ['spec'],
  mochaOpts: {
    ui: 'bdd',
    compilers: ['js:babel-core/register'],
  },
}

但是wdio日志记录表明它在每个规范文件之前创建了一个新会话。

更糟糕的是,如果我使用--mochaOpts.grep,它仍会经历为每个规范文件创建新会话的过程,即使该文件中的测试实际上没有运行,这也是不必要的时间。

如何让wdio在开始时启动一个会话,而不是在为每个spec文件运行测试之前创建新会话?

我正在寻找一种更好的方法,而不仅仅是specs: ['./test/allTests.js']并手动导入allTests.js中的所有不同规范文件。

0 个答案:

没有答案