Skip to main content

abort

Overview

Use the abort command to abort a request with a specified error.

A request can be aborted with one of the following errors:

  • Failed
  • Aborted
  • TimedOut
  • AccessDenied
  • ConnectionClosed | ConnectionReset | ConnectionRefused | ConnectionAborted | ConnectionFailed
  • NameNotResolved
  • InternetDisconnected
  • AddressUnreachable
  • BlockedByClient | BlockedByResponse

Usage

mock.abort(errorCode);

Command Parameters

NameTypeDescription
errorCodeErrorCodeThe response error code. Possible values are listed above.

Usage Examples

it("should block Google Analytics from page", async ({ browser }) => {
const mock = await browser.mock("https://www.google-analytics.com/**");
mock.abort("Failed");
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.