I would like to use nock for mocking HTTP requests in puppeteer but for doing it nock should run in the same node process. Is there any solution or workaround for that?
nock has great functionality that relevant also for e2e tests or scrapers
I would like to use nock for mocking HTTP requests in puppeteer but for doing it nock should run in the same node process. Is there any solution or workaround for that?
nock has great functionality that relevant also for e2e tests or scrapers
This is not currently possible.
Unfortunately, running in the same process is only one of the problems. Puppeteer works by controlling a Chrome browser, usually headless. Browsers make outbound HTTP calls via XHR/fetch while Nock works by monkey patching the HTTP lib native to Node. So even if you setup Nock in the same process as the one making the request, Nock would not be able to intercept it.