abort
使用以下錯誤代碼之一中止請求: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://127.0.0.1/**')
mock.abort('Failed')
})