# waitForResponse

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

## Usage[​](#usage "Direct link to Usage")

```
mock.waitForResponse({ timeout, interval, timeoutMsg })
```

## Parameters[​](#parameters "Direct link to Parameters")

| Name                                 | Type             | Details                                                             |
| ------------------------------------ | ---------------- | ------------------------------------------------------------------- |
| `options`<br />*optional*            | `WaitForOptions` | wait options                                                        |
| `options.timeout`<br />*optional*    | `Number`         | max wait time in ms (defaults to `browser.options.waitforTimeout`)  |
| `options.interval`<br />*optional*   | `Number`         | poll interval in ms (defaults to `browser.options.waitforInterval`) |
| `options.timeoutMsg`<br />*optional* | `String`         | custom timeout error message                                        |

## Example[​](#example "Direct link to 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)
})
```
