How to use the webpagetest/lib/helper.WPTAPIError function in webpagetest

To help you get started, we’ve selected a few webpagetest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sitespeedio / sitespeed.io / lib / plugins / webpagetest / analyzer.js View on Github external
data.data.median.firstView.chromeUserTiming.forEach(measure => {
          chromeUserTiming[measure.name] = measure.time;
        });
        data.data.median.firstView.chromeUserTiming = chromeUserTiming;
        log.verbose(
          'detected chromeUserTiming and restructured them to :%:2j',
          chromeUserTiming
        );
      }

      const promises = [];
      let har;
      promises.push(
        getHARData(id, {})
          .then(theHar => (har = theHar))
          .catch(WPTAPIError, error =>
            log.warn(
              `Couldn't get HAR for id ${id} ${error.message} (url = ${url})`
            )
          )
      );

      const traces = {};
      const views = ['firstView'];
      if (!wptOptions.firstViewOnly) {
        views.push('repeatView');
      }

      views.forEach(function(view) {
        for (let run = 1; run <= wptOptions.runs; run++) {
          // The WPT API wrapper mutates the options object, why ohh why?!?!?!
          const repeatView = view === 'repeatView';
github sitespeedio / sitespeed.io / lib / plugins / webpagetest / analyzer.js View on Github external
promises.push(
            getWaterfallImage(id, {
              run,
              chartType: 'connection',
              repeatView
            })
              .then(img =>
                storageManager.writeDataForUrl(
                  img,
                  'wpt-waterfall-connection' + run + '-' + view + '.png',
                  url,
                  'waterfall'
                )
              )
              .catch(WPTAPIError, error =>
                log.warn(
                  `Couldn't get connection waterfall for id ${id}, run ${run}: ${
                    error.message
                  } (url = ${url})`
                )
              )
          );

          if (wptOptions.timeline) {
            promises.push(
              getChromeTraceData(id, {
                run,
                repeatView
              })
                .then(
                  trace => (traces['trace-' + run + '-wpt-' + view] = trace)

webpagetest

WebPageTest API wrapper for NodeJS

MIT
Latest version published 19 days ago

Package Health Score

75 / 100
Full package analysis