Best way to intercept XHR request on page with Puppeteer and return mock response
It seems that the way to go is request.respond() indeed, but still, I couldn’t find a concrete example in the web on how to use it. The way I did it was like this: // Intercept API response and pass mock data for Puppeteer await page.setRequestInterception(true); page.on(‘request’, request => { if (request.url() === constants.API) { … Read more