メインコンテンツへスキップ

abortOnce

次のいずれかのエラーコードでリクエストを一度だけ中断します:FailedAbortedTimedOutAccessDeniedConnectionClosedConnectionResetConnectionRefusedConnectionAbortedConnectionFailedNameNotResolvedInternetDisconnectedAddressUnreachableBlockedByClientBlockedByResponse

使い方
mock.abortOnce(errorCode)
パラメータ
名前詳細
errorCodeErrorCodeレスポンスのエラーコード。次のいずれかになります:FailedAbortedTimedOutAccessDeniedConnectionClosedConnectionResetConnectionRefusedConnectionAbortedConnectionFailedNameNotResolvedInternetDisconnectedAddressUnreachableBlockedByClientBlockedByResponse
abortOnce.js
it('should block mock only once', async () => {
const mock = await browser.mock('https://webdriverio.dokyumento.jp')
mock.abortOnce('Failed')

await browser.url('https://webdriverio.dokyumento.jp')
// catch failing command as page can't be loaded
.catch(() => {})
console.log(await browser.getTitle()) // outputs: ""

await browser.url('https://webdriverio.dokyumento.jp')
console.log(await browser.getTitle()) // outputs: "WebdriverIO · Next-gen browser and mobile automation test framework for Node.js"
})

ようこそ! ご用件は何ですか?

WebdriverIO AI Copilot