中止
使用以下错误代码之一中止请求:
Failed
, Aborted
, TimedOut
, AccessDenied
, ConnectionClosed
,
ConnectionReset
, ConnectionRefused
, ConnectionAborted
,
ConnectionFailed
, NameNotResolved
, InternetDisconnected
,
AddressUnreachable
, BlockedByClient
, BlockedByResponse
.
用法
mock.abort(errorCode)
参数
名称 | 类型 | 详情 |
---|---|---|
errorCode | ErrorCode | 响应的错误代码,可以是以下之一:Failed , Aborted , TimedOut , AccessDenied , ConnectionClosed , ConnectionReset , ConnectionRefused , ConnectionAborted , ConnectionFailed , NameNotResolved , InternetDisconnected , AddressUnreachable , BlockedByClient , BlockedByResponse |
示例
abort.js
it('should block Google Analytics from page', async () => {
const mock = await browser.mock('https://www.google-analytics.com/**')
mock.abort('Failed')
})