Skip to main content
Version: v8

mockRestoreAll

Overview

Use the mockRestoreAll command to restore the information and behavior in registered mocks to their original state. Mocks are registered using the mock command.

Usage

await browser.mockRestoreAll();

Usage Examples

it("should restore all mocks", async ({ browser }) => {
const googleMock = await browser.mock("https://google.com/");
googleMock.respond("https://webdriver.io");
const wdioMock = await browser.mock("https://webdriver.io");
wdioMock.respond("http://json.org");

await browser.url("https://google.com/");
console.log(await browser.getTitle()); // JSON

await browser.mockRestoreAll();

await browser.url("https://google.com/");
console.log(await browser.getTitle()); // Google
});

References

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