abort
Abort the request with one of the following error codes:
Failed
, Aborted
, TimedOut
, AccessDenied
, ConnectionClosed
,
ConnectionReset
, ConnectionRefused
, ConnectionAborted
,
ConnectionFailed
, NameNotResolved
, InternetDisconnected
,
AddressUnreachable
, BlockedByClient
, BlockedByResponse
.
Usage
mock.abort(errorCode)
Parameters
Name | Type | Details |
---|---|---|
errorCode | ErrorCode | error code of the response, can be one of: Failed , Aborted , TimedOut , AccessDenied , ConnectionClosed , ConnectionReset , ConnectionRefused , ConnectionAborted , ConnectionFailed , NameNotResolved , InternetDisconnected , AddressUnreachable , BlockedByClient , BlockedByResponse |
Example
abort.js
it('should block Google Analytics from page', async () => {
const mock = await browser.mock('https://www.google-analytics.com/**')
mock.abort('Failed')
})