WebdriverIO
npm install @tracera/webdriverio
Requires Node.js ≥ 22.19 and WebdriverIO ≥ 9 (see Autotest adapters). @tracera/webdriverio on npm.
In wdio.conf.ts (Mocha):
export const config = {
reporters: ['spec', ['@tracera/webdriverio/reporter', {}]],
services: [['@tracera/webdriverio/service', {}]],
mochaOpts: {
require: ['@tracera/webdriverio/setup'],
},
};
For Cucumber, register the same reporter and service. Prefer Scenario tags @tracera.id:‹id› (optional @tracera.name:…), or call tracera.testCase from a Before hook / step.
Only the final WebdriverIO attempt is reported when retries are enabled. If that attempt is a retry (retry > 0), the result Env tab includes WEBDRIVERIO_RETRY (1 is the second run).
Environment variables and run mode: Autotest adapters.
Bind testCaseId and autotestName
Load @tracera/webdriverio/setup via mochaOpts.require (patches Mocha globals) and import tracera / annotations. If you omit autotestName, the adapter uses the Mocha / Scenario title.
Mocha — at declaration (preferred):
import { annotations } from '@tracera/webdriverio';
it(
'login',
annotations(42, 'e2e/login', async () => {
await browser.url('https://example.com');
}),
);
When Mocha accepts an options object as the second argument, you can also write
it("login", annotations(42, "e2e/login"), async () => { … }).
Mocha — inside the test (optional if annotations already bind the case):
import { tracera } from '@tracera/webdriverio';
it('login', async () => {
tracera.testCase(42, 'e2e/login');
await browser.url('https://example.com');
});
Cucumber — Scenario tags (preferred):
@tracera.id:42
@tracera.name:e2e%2Flogin
Scenario: login
Given I open the login page
Omit @tracera.name:… to use the Scenario title as autotestName. To bind without Scenario tags, call tracera.testCase from a Before hook / step.
Steps
Use tracera.step. With @tracera/webdriverio/setup, stock Mocha beforeEach / afterEach are instrumented — steps inside them go to Setup / Teardown.
import { tracera } from '@tracera/webdriverio';
beforeEach(async () => {
await tracera.step('open shop', async () => {
await browser.url('/shop');
});
});
it('checkout', async () => {
tracera.testCase(10, 'e2e/checkout');
await tracera.step('add to cart', async () => {
await $('[data-testid=add]').click();
});
});
afterEach(async () => {
await tracera.step('cleanup', async () => {
await browser.url('/cart/clear');
});
});
Comments, errors, and attachments
Inside a step — fields on that step. Outside a step — fields on the result. Use tracera.attachment for files (at most 10 on the result and on each step).
import { tracera } from '@tracera/webdriverio';
it('login', async () => {
tracera.testCase(42, 'e2e/login');
tracera.comment('result-level note');
tracera.error('result-level error text');
await tracera.step('open login', async () => {
await browser.url('/login');
tracera.comment('landed on login');
tracera.attachment({
fileName: 'suite-log.txt',
mimeType: 'text/plain',
data: new TextEncoder().encode('finished login flow'),
});
});
});