run all webdriver.io spec files in single browser session

704 views Asked by At

I'm using wdio to run tests on my local machine; I start up a single server and run tests on it. I reduced maxInstances to 1 so that there are no problems resetting the database before each test.

My config is:

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'],
  },
}

But wdio logging indicates that it creates a new session before each spec file.

What's worse, if I use --mochaOpts.grep, it still goes through the process of creating a new session for each spec file, even if no tests in that file actually run, which is needlessly time-consuming.

How can I make wdio start one session at the beginning, and not create new sessions before running tests for each spec file?

I'm looking for a better way than just having specs: ['./test/allTests.js'] and manually importing all the different spec files in allTests.js.

0

There are 0 answers