How to use browsertime - 10 common examples

To help you get started, we’ve selected a few browsertime 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 / bin / browsertimeWebPageReplay.js View on Github external
connectivity: {
      profile: 'native',
      downstreamKbps: undefined,
      upstreamKbps: undefined,
      latency: undefined,
      engine: 'external'
    },
    viewPort: '1366x708',
    delay: 0,
    video: false,
    visualMetrics: false,
    resultDir: '/tmp/browsertime'
  };

  const btOptions = merge({}, parsed.argv.browsertime, defaultConfig);
  browsertime.logging.configure(parsed.argv);

  // We have a special hack in sitespeed.io when you set --mobile
  if (parsed.argv.mobile) {
    btOptions.viewPort = '360x640';
    btOptions['view-port'] = '360x640';
    if (btOptions.browser === 'chrome') {
      const emulation = get(
        btOptions,
        'chrome.mobileEmulation.deviceName',
        'iPhone 6'
      );
      btOptions.chrome.mobileEmulation = {
        deviceName: emulation
      };
    } else {
      btOptions.userAgent = iphone6UserAgent;
github sitespeedio / sitespeed.io / lib / plugins / browsertime / index.js View on Github external
open(context, options) {
    this.make = context.messageMaker('browsertime').make;
    this.useAxe = options.axe && options.axe.enable;
    this.options = merge({}, defaultConfig, options.browsertime);
    this.allOptions = options;
    merge(this.options, { verbose: options.verbose });
    this.firstParty = options.firstParty;
    this.options.mobile = options.mobile;
    this.storageManager = context.storageManager;
    this.resultUrls = context.resultUrls;
    this.postChromeTrace = options.postChromeTrace;
    this.pluginScripts = [];
    this.pluginAsyncScripts = [];
    browsertime.logging.configure(options);
    this.screenshotType = get(
      options,
      'browsertime.screenshotParams.type',
      defaultConfig.screenshotParams.type
    );
    this.scriptOrMultiple = options.multi;

    // hack for disabling viewport on Android that's not supported
    if (
      this.options.chrome &&
      this.options.chrome.android &&
      this.options.chrome.android.package
    ) {
      this.options.viewPort = undefined;
    }
github sitespeedio / sitespeed.io / lib / analyze / browsertime.js View on Github external
logDir: config.run.absResultDir,
		waitScript: config.waitScript,
		customScripts: config.customScripts,
		seleniumServer: config.seleniumServer,
		useProxy: true
	};

	if (config.btConfig) {
		Object.keys(config.btConfig).forEach(function(key) {
			btConfig[key] = config.btConfig[key];
		});
	}

	log.log('info', 'Running browsertime for ' + browser + ' ' + url);

	browsers.setProxy(proxy);

	var bt = new Browsertime(browsers);

	browserListenerProxy.setup(bt, proxy, btConfig);

	bt.fetch(btConfig, function(err) {
		if (err) {
			return callback(err);
		}
		fs.readFile(measurementFile, function(err2, btData) {
			if (err2) {
				log.log('error', 'Couldn\'t read the file:' + measurementFile);
				return callback(err2);
			}

			// TODO we should only read the HAR if we ask for one
github sitespeedio / sitespeed.io / lib / analyze / browsertime.js View on Github external
useProxy: true
	};

	if (config.btConfig) {
		Object.keys(config.btConfig).forEach(function(key) {
			btConfig[key] = config.btConfig[key];
		});
	}

	log.log('info', 'Running browsertime for ' + browser + ' ' + url);

	browsers.setProxy(proxy);

	var bt = new Browsertime(browsers);

	browserListenerProxy.setup(bt, proxy, btConfig);

	bt.fetch(btConfig, function(err) {
		if (err) {
			return callback(err);
		}
		fs.readFile(measurementFile, function(err2, btData) {
			if (err2) {
				log.log('error', 'Couldn\'t read the file:' + measurementFile);
				return callback(err2);
			}

			// TODO we should only read the HAR if we ask for one
			fs.readFile(harFile, function(err3, harData) {
				if (err3) {
					log.log('error', 'Couldn\'t read the file:' + harFile);
					return callback(err3);
github sitespeedio / coach / test / help / browsertimeRunner.js View on Github external
createTestRunner(browser, category, useHttp2) {
    function run(url, script) {
      return Promise.resolve(script).then(script =>
        runner
          .loadAndWait(url, 'return window.performance.timing.loadEventEnd>0')
          .then(() => runner.runScript(script))
      );
    }

    const runner = new browsertime.SeleniumRunner({
      browser: browser,
      timeouts: {
        browserStart: 60000
      }
    });

    let baseUrl;

    return {
      start() {
        return webserver
          .startServer(useHttp2)
          .then(address => {
            baseUrl = urlParser.format({
              protocol: useHttp2 ? 'https' : 'http',
              hostname: address.address,
github sitespeedio / coach / test / help / browsertimeSingleScript.js View on Github external
start: function(browser) {
    bt.logging.configure({});
    runner = new bt.SeleniumRunner({
      browser: browser,
      'timeouts': {
        'browserStart': 20000
      }
    });
    return runner.start();
  },
  stop: function() {
github sitespeedio / coach / test / help / browsertime.js View on Github external
start: function(browser) {
    bt.logging.configure({});
    runner = new bt.SeleniumRunner({
      browser: browser,
      'timeouts': {
        'browserStart': 20000
      }
    });
    return runner.start();
  },
  stop: function() {
github sitespeedio / coach / test / help / browsertimeRunner.js View on Github external
'use strict';

let Promise = require('bluebird'),
  browsertime = require('browsertime'),
  urlParser = require('url'),
  fs = require('fs'),
  webserver = require('./webserver'),
  path = require('path');

Promise.promisifyAll(fs);

browsertime.logging.configure({});

function getScript(ruleFileName, category) {
  const domPath = path.resolve(__dirname, '..', '..', 'lib', 'dom'),
    utilPath = path.resolve(domPath, 'util.js'),
    utilScript = fs.readFileAsync(utilPath, 'utf8'),
    rulePath = path.resolve(domPath, category, ruleFileName),
    ruleScript = fs.readFileAsync(rulePath, 'utf8');

  return Promise.join(
    utilScript,
    ruleScript,
    (utilScript, ruleScript) => utilScript + ' return ' + ruleScript
  );
}

module.exports = {
github sitespeedio / coach / test / help / browsertime.js View on Github external
start: function(browser) {
    bt.logging.configure({});
    runner = new bt.SeleniumRunner({
      browser: browser,
      'timeouts': {
        'browserStart': 20000
      }
    });
    return runner.start();
  },
  stop: function() {
github sitespeedio / coach / test / help / browsertimeSingleScript.js View on Github external
start: function(browser) {
    bt.logging.configure({});
    runner = new bt.SeleniumRunner({
      browser: browser,
      'timeouts': {
        'browserStart': 20000
      }
    });
    return runner.start();
  },
  stop: function() {

browsertime

Get performance metrics from your web page using Browsertime.

Apache-2.0
Latest version published 2 days ago

Package Health Score

81 / 100
Full package analysis

Similar packages