The Mock Object
The mock object is an object that represents a network mock and contains information about requests that were matching given url
and filterOptions
. It can be received using the mock
command.
Note that using the mock
command requires support for Chrome DevTools protocol.
That support is given if you run tests locally in Chromium based browser or if
you use a Selenium Grid v4 or higher. This command can not be used when running
automated tests in the cloud. Find out more in the Automation Protocols section.
You can read more about mocking requests and responses in WebdriverIO in our Mocks and Spies guide.
Propertiesβ
A mock object contains the following properties:
Name | Type | Details |
---|---|---|
url | String | The url passed into the mock command |
filterOptions | Object | The resource filter options passed into the mock command |
browser | Object | The Browser Object used to get the mock object. |
matches | Object[] | Information about matching browser requests, containing properties such as url , method , headers , initialPriority , referrerPolic , statusCode , responseHeaders and body |
Methodsβ
Mock objects provide various commands, listed in the mock
section, that allow users to modify the behavior of the request or response.