Skip to main content

waitForResponse

Wait until at least one matching request has received a response.

Usage
mock.waitForResponse({ timeout, interval, timeoutMsg })
Parameters
NameTypeDetails
options
optional
WaitForOptionswait options
options.timeout
optional
Numbermax wait time in ms (defaults to browser.options.waitforTimeout)
options.interval
optional
Numberpoll interval in ms (defaults to browser.options.waitforInterval)
options.timeoutMsg
optional
Stringcustom timeout error message
Example
waitForResponse.js
it('should wait for a matching response', async () => {
const mock = await browser.mock('**' + '/users/list')

// trigger action that issues the request
await $('#load').click()

await mock.waitForResponse({ timeout: 5000 })
expect(mock.calls.length).toBeGreaterThan(0)
})

Welcome! How can I help?

WebdriverIO AI Copilot