Organizing Test Suite
As projects grow, inevitably more and more integration tests are added. This increases build time and slows productivity.
To prevent this, you should run your tests in parallel. WebdriverIO already tests each spec (or feature file in Cucumber) in parallel within a single session. In general, try to test only a single feature per spec file. Try to not have too many or too few tests in one file. (However, there is no golden rule here.)
Once your tests have several spec files, you should start running your tests concurrently. To do so, adjust the maxInstances
property in your config file. WebdriverIO allows you to run your tests with maximum concurrency—meaning that no matter how many files and tests you have, they can all run in parallel. (This is still subject to certain limits, like your computer’s CPU, concurrency restrictions, etc.)
Let's say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have set
maxInstances
to1
. The WDIO test runner will spawn 3 processes. Therefore, if you have 10 spec files and you setmaxInstances
to10
, all spec files will be tested simultaneously, and 30 processes will be spawned.
You can define the maxInstances
property globally to set the attribute for all browsers.
If you run your own WebDriver grid, you may (for example) have more capacity for one browser than another. In that case, you can limit the maxInstances
in your capability object:
// wdio.conf.js
export const config = {
// ...
// set maxInstance for all browser
maxInstances: 10,
// ...
capabilities: [{
browserName: 'firefox'
}, {
// maxInstances can get overwritten per capability. So if you have an in-house WebDriver
// grid with only 5 firefox instance available you can make sure that not more than
// 5 instance gets started at a time.
browserName: 'chrome'
}],
// ...
}