Skip to content

WebdriverIO

Welcome!

This guide connects your WebdriverIO tests to Testomat.io. By the end of this guide you will have:

  • your WebdriverIO tests imported into Testomat.io
  • test IDs synced between your code and your project
  • run reports with screenshots and artifacts attached
  • parallel runs reporting into a single run

WebDriver.io setup flow chart

Importing brings the tests you already have into Testomat.io, so you can plan, run, and report on them. Everything starts on the Imports page.

  1. In the Project Framework field, select webdriverio.
  2. In the Project Language field, select JavaScript or TypeScript.
  3. Under Import tests, select your operating system.
  4. Copy the command that appears.

Set up WebdriverIO project import

After you’re done with the setup:

  1. Open a terminal.
  2. Navigate to your project folder and run the copied command.
  3. When the terminal prints how many tests it found, the import worked.
  4. Your tests are now on the Tests page.

Don’t have your own WebDriverIO project yet? Check out our demo project.

For more details, see Import Tests from Source Code.

You can change how tests are imported:

OptionDescription
Auto-assign IdsAssigns a unique ID to each test.
Purge Old IdsRemoves previously set IDs from tests.
Disable Detached TestsDisables tests marked as detached.
Prefer Source Code StructureKeeps your source code structure in the test hierarchy.

Parametrized tests run the same scenario with different data. To keep those values visible in Testomat.io, write test names with template literals:

const people = ['Alice', 'Bob'];
describe('my tests', () => {
for (const name of people) {
it(`testing with ${name}`, async () => {
// ...
});
}
});

The test is imported with the placeholder in its name, and your reports show the real parameter values.

Webdriverio parametrized tests in editor

A test ID links a test in your code to its test case in Testomat.io. Turn on Auto-assign Ids (--update-ids) during import, and Testomat.io writes an ID into each test.

From then on it tracks changes to that test instead of creating duplicates as your project grows.

it('user should be fine @T12345678', () => {
it('user should be fine', () => {
expect(user).toBe('fine');
});

Your tests now carry the same IDs in your code and in your project.

Webdriverio tests with IDs in editor

Reports show what passed, what failed, and why. WebdriverIO can add screenshots and visual comparisons before the results reach Testomat.io. Pick whichever fits your setup:

  • Timeline Reporter gives a visual view of your results, with screenshots that make failures easy to spot.
  • @wdio/visual-service compares screenshots against baseline images to catch visual regressions.
  • Built-in methods such as browser.saveScreenshot() capture the whole page or a single element.

To capture a screenshot every time a test fails, add this to your config:

afterTest: async function (test, context, { error, result, duration, passed, retries }) {
if (error) {
await browser.takeScreenshot();
}
}

Screenshots, videos, and logs make a failure much easier to diagnose. The Testomat.io reporter uploads these files to your own S3 bucket and links them to the matching test cases.

WebDriver.io S3 bucket setup chart

  1. In WebdriverIO, enable the artifacts you want - for example screenshots and logs.
  2. Connect your S3 Bucket to Testomat.io.
  3. Open a test inside a run report to view or download its artifacts.

Testomatio artifacts setup

To attach a screenshot, save it to a file first:

await driver.takeScreenshot().then((image) => {
require('fs').writeFileSync('screenshot.png', image, 'base64');
});

When you split tests across parallel workers, each worker reports its own run by default. To collect them into a single run, give every worker the same title and set TESTOMATIO_SHARED_RUN:

Terminal window
TESTOMATIO_TITLE="Parallel Test Run ${GIT_COMMIT}" TESTOMATIO_SHARED_RUN=1 <actual run command>

To extend the shared run timeout (default: 20 minutes), use the TESTOMATIO_SHARED_RUN_TIMEOUT variable.

Example:

Terminal window
TESTOMATIO_SHARED_RUN_TIMEOUT=120 TESTOMATIO_SHARED_RUN=1 &lt;actual run command>

The simplest way to run WebdriverIO in parallel is through the Testomat.io CLI, which handles every worker for you:

Terminal window
npx @testomatio/reporter run 'npx wdio [wdio.conf.js](wdio.conf.js)'