清除所有模拟
重置会话中所有已注册模拟存储的所有信息。
用法
browser.mockClearAll()
示例
mockClearAll.js
it('should clear all mocks', async () => {
const docMock = await browser.mock('**', {
headers: { 'Content-Type': 'text/html' }
})
const jsMock = await browser.mock('**', {
headers: { 'Content-Type': 'application/javascript' }
})
await browser.url('http://guinea-pig.webdriver.io/')
console.log(docMock.calls.length, jsMock.calls.length) // returns "1 4"
await browser.url('http://guinea-pig.webdriver.io/')
console.log(docMock.calls.length, jsMock.calls.length) // returns "2 4" (JavaScript comes from cache)
await browser.mockClearAll()
console.log(docMock.calls.length, jsMock.calls.length) // returns "0 0"
})