UNPKG

phantomas

Version:

Headless Chromium-based web performance metrics collector and monitoring tool

25 lines (18 loc) 644 B
/** * Delays report generation for a given time */ "use strict"; const { setTimeout: setTimeoutAsync } = require("timers/promises"); module.exports = function (phantomas) { // e.g. --post-load-delay 5 var delay = parseInt(phantomas.getParam("post-load-delay"), 10); if (!delay) { return; } // https://github.com/GoogleChrome/puppeteer/blob/v1.11.0/docs/api.md#framewaitforselectororfunctionortimeout-options-args phantomas.log("Will wait %d second(s) after load", delay); phantomas.on("beforeClose", async () => { phantomas.log("Sleeping for %d seconds", delay); return setTimeoutAsync(delay * 1000); }); };