Generating HAR files

A .HAR file is a standardized JSON file which contains all the HTTP requests made by the browser.

It is most often used in combination with HAR-viewers to explore the performance of a website in a browser.

To get started, please install the puppeteer-har package:

npm install puppeteer-har

Next, run a sample test which will open our website and generate a HAR file:

const puppeteer = require('puppeteer');
const PuppeteerHar = require('puppeteer-har');
(async () => {
  const browser = await puppeteer.connect({
    browserWSEndpoint: 'wss://[YOUR-TOKEN]'
  const page = await browser.newPage();
  const har = new PuppeteerHar(page);
  await har.start({ path: 'results.har' });
  await page.goto('');
  await har.stop();
  await browser.close();