Ensure that there no waits in tests directly including before/after hooks. Wait commands should be moved to page objects or to an other abstraction layer for better readibility and mainability of tests (usually less verbose).
Examples of incorrect code for this rule:
it(() => {
page.waitFor('.abc'); // options: 'puppeteer'
});
beforeEach(() => {
t.wait(200); // options: 'testcafe'
});
test.concurrent.only(() => {
element.waitForExists(); // options: 'webdriverio'
});
it(() => {
// options: 'webdriverio'
browser.waitUntil(function () {
$('#someText').getText() === 'I am now different',
{ timeout: 5000, timeoutMsg: 'expected text to be different after 5s' };
});
});
Examples of correct code for this rule:
someMethod() {
// options: 'playwright'
page.waitForSelector('#id');
}
someMethod() {
// options: 'puppeteer'
page.waitFor('.abc');
}
someMethod() {
// options: 'testcafe'
t.wait(200);
}
someMethod() {
// options: 'webdriverio'
element.waitForDisplayed();
}
The supported automation tools for this rule are: playwright
, puppeteer
, testcafe
and webdriverio
.
{
"ui-testing/no-wait-in-tests": ["error", "webdriverio"]
}