This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function useMocks(page, mocks) { | |
await page.setRequestInterception(true); | |
page.on("request", async (request) => { | |
if (request.postData() && JSON.parse(request.postData()).operationName) { | |
const mock = mocks.find( | |
(mock) => mock.name === JSON.parse(request.postData()).operationName | |
); | |
if (mock) { | |
await delay(500); | |
request.respond({ |