abortOnce
Brechen Sie die Anfrage einmal mit einem der folgenden Fehlercodes ab:
Failed
, Aborted
, TimedOut
, AccessDenied
, ConnectionClosed
,
ConnectionReset
, ConnectionRefused
, ConnectionAborted
,
ConnectionFailed
, NameNotResolved
, InternetDisconnected
,
AddressUnreachable
, BlockedByClient
, BlockedByResponse
.
Verwendung
mock.abortOnce(errorCode)
Parameter
Name | Typ | Details |
---|---|---|
errorCode | ErrorCode | Fehlercode der Antwort, kann einer der folgenden sein: Failed , Aborted , TimedOut , AccessDenied , ConnectionClosed , ConnectionReset , ConnectionRefused , ConnectionAborted , ConnectionFailed , NameNotResolved , InternetDisconnected , AddressUnreachable , BlockedByClient , BlockedByResponse |
Beispiel
abortOnce.js
it('should block mock only once', async () => {
const mock = await browser.mock('https://webdriver.io')
mock.abortOnce('Failed')
await browser.url('https://webdriver.io')
// catch failing command as page can't be loaded
.catch(() => {})
console.log(await browser.getTitle()) // outputs: ""
await browser.url('https://webdriver.io')
console.log(await browser.getTitle()) // outputs: "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js"
})