Search code examples
mocha.jswebdriver-io

Webdriver io running in Parallel - How to ensure one test spec runs before another one - execution order


I have inherited a webdriver io - mocha test framework. Until now the tests have been ran one at a time. There was one test spec that had to be ran before the other. This was just handled in the file naming convention:

aFirstTest.js
xLastTest.js

So when the whole suite was ran, this ensured that aFirstTest.js was ran before xLastTest.js

I now want to run the tests in parallel mode.

How can I ensure that aFirstTest.js is ran before xLastTest.js?


Solution

  • This post might give you some ideas.

    Otherwise, you'd need to present the specs to WebdriverIO as one. An easy way to do this would be wrapping them in another file.

    wrapper.spec.js:

    const first = require('./aFirstTest')
    const last = require('./xLastTest')
    

    And in your config:

    suites: {
            firstLast: [
                './specs/wrapper.spec.js'
            ]
    }