Socket
Socket
Sign inDemoInstall

webpagetest

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpagetest - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

13

lib/mapping.js

@@ -240,2 +240,11 @@ /**

//throttle_cpu param
throttleCPU: {
name: "throttleCPU",
key: "thc",
api: "throttle_cpu",
param: "number",
info: "custom cpu throttling",
},
// Auth tab

@@ -660,2 +669,6 @@ login: {

},
proxy: {
name: "proxy",
info: "set the proxy used to fetch results",
},
},

@@ -662,0 +675,0 @@ waterfall: {

681

lib/webpagetest.js

@@ -8,51 +8,52 @@ /**

var http = require('http'),
https = require('https'),
url = require('url'),
path = require('path'),
zlib = require('zlib'),
specs = require('./specs'),
helper = require('./helper'),
server = require('./server'),
mapping = require('./mapping');
var http = require("http"),
https = require("https"),
url = require("url"),
path = require("path"),
zlib = require("zlib"),
specs = require("./specs"),
helper = require("./helper"),
server = require("./server"),
mapping = require("./mapping");
var reSpace = /\s/,
reConnectivity = /^(?:Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom)$/,
reHTMLOutput = /<h\d[^<]*>([^<]+)<\/h\d>/; // for H3 on cancelTest.php
reConnectivity =
/^(?:Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom)$/,
reHTMLOutput = /<h\d[^<]*>([^<]+)<\/h\d>/; // for H3 on cancelTest.php
var paths = {
testStatus: 'testStatus.php',
testResults: 'jsonResult.php',
locations: 'getLocations.php',
testers: 'getTesters.php',
testBalance: 'testBalance.php',
test: 'runtest.php',
gzip: 'getgzip.php',
har: 'export.php',
waterfall: 'waterfall.php',
thumbnail: 'thumbnail.php',
cancel: 'cancelTest.php',
history: 'testlog.php',
videoCreation: 'video/create.php',
videoView: 'video/view.php',
googleCsi: 'google/google_csi.php',
responseBody: 'response_body.php',
timeline: 'getTimeline.php'
testStatus: "testStatus.php",
testResults: "jsonResult.php",
locations: "getLocations.php",
testers: "getTesters.php",
testBalance: "testBalance.php",
test: "runtest.php",
gzip: "getgzip.php",
har: "export.php",
waterfall: "waterfall.php",
thumbnail: "thumbnail.php",
cancel: "cancelTest.php",
history: "testlog.php",
videoCreation: "video/create.php",
videoView: "video/view.php",
googleCsi: "google/google_csi.php",
responseBody: "response_body.php",
timeline: "getTimeline.php",
};
var filenames = {
pageSpeed: 'pagespeed.txt',
utilization: 'progress.csv',
request: 'IEWTR.txt',
netLog: 'netlog.txt',
chromeTrace: 'trace.json',
consoleLog: 'console_log.json',
testInfo: 'testinfo.json',
history: 'history.csv',
waterfall: 'waterfall.png',
screenshot: 'screen.jpg',
screenshotStartRender: 'screen_render.jpg',
screenshotDocumentComplete: 'screen_doc.jpg',
screenshotFullResolution: 'screen.png',
cached: '_Cached'
pageSpeed: "pagespeed.txt",
utilization: "progress.csv",
request: "IEWTR.txt",
netLog: "netlog.txt",
chromeTrace: "trace.json",
consoleLog: "console_log.json",
testInfo: "testinfo.json",
history: "history.csv",
waterfall: "waterfall.png",
screenshot: "screen.jpg",
screenshotStartRender: "screen_render.jpg",
screenshotDocumentComplete: "screen_doc.jpg",
screenshotFullResolution: "screen.png",
cached: "_Cached",
};

@@ -62,15 +63,14 @@

function get(config, pathname, proxy, agent, callback, encoding) {
var protocol,
options;
var protocol, options;
if (proxy) {
var proxyUrl = url.parse(proxy);
var pathForProxy = config.protocol + '//';
var pathForProxy = config.protocol + "//";
if (config.auth) {
pathForProxy += config.auth + '@';
pathForProxy += config.auth + "@";
}
pathForProxy += config.hostname + ':' + config.port + pathname;
protocol = (proxyUrl.protocol === 'https:' ? https : http);
pathForProxy += config.hostname + ":" + config.port + pathname;
protocol = proxyUrl.protocol === "https:" ? https : http;

@@ -82,7 +82,7 @@ options = {

headers: {
Host: config.hostname
}
Host: config.hostname,
},
};
} else {
protocol = (config.protocol === 'https:' ? https : http);
protocol = config.protocol === "https:" ? https : http;
options = {

@@ -93,8 +93,8 @@ path: pathname,

port: config.port,
headers: {}
headers: {},
};
}
if (encoding !== 'binary') {
options.headers['accept-encoding'] = 'gzip,deflate';
if (encoding !== "binary") {
options.headers["accept-encoding"] = "gzip,deflate";
}

@@ -106,55 +106,60 @@

return protocol.get(options, function getResponse(res) {
var data, length,
return protocol
.get(options, function getResponse(res) {
var data,
length,
statusCode = res.statusCode;
if (statusCode !== 200) {
callback(
new helper.WPTAPIError(statusCode, http.STATUS_CODES[statusCode])
);
} else {
data = [];
length = 0;
if (statusCode !== 200) {
callback(
new helper.WPTAPIError(statusCode, http.STATUS_CODES[statusCode])
);
} else {
data = [];
length = 0;
encoding = res.headers['content-encoding'] || encoding || 'uft8';
encoding = res.headers["content-encoding"] || encoding || "uft8";
res.on('data', function onData(chunk) {
data.push(chunk);
length += chunk.length;
});
res.on("data", function onData(chunk) {
data.push(chunk);
length += chunk.length;
});
res.on('end', function onEnd() {
var i, len, pos,
res.on("end", function onEnd() {
var i,
len,
pos,
buffer = new Buffer.alloc(length),
type = (res.headers['content-type'] || '').split(';')[0];
type = (res.headers["content-type"] || "").split(";")[0];
for (i = 0, len = data.length, pos = 0; i < len; i += 1) {
data[i].copy(buffer, pos);
pos += data[i].length;
}
for (i = 0, len = data.length, pos = 0; i < len; i += 1) {
data[i].copy(buffer, pos);
pos += data[i].length;
}
if (encoding === 'gzip' || encoding === 'deflate') {
// compressed response (gzip,deflate)
zlib.unzip(buffer, function unzip(err, buffer) {
if (err) {
callback(err);
} else {
callback(undefined, buffer.toString(), {
type: type,
encoding: encoding
});
}
});
} else {
// uncompressed response
callback(undefined, buffer, {
type: type,
encoding: encoding
});
}
});
}
}).on('error', function onError(err) {
callback(err);
});
if (encoding === "gzip" || encoding === "deflate") {
// compressed response (gzip,deflate)
zlib.unzip(buffer, function unzip(err, buffer) {
if (err) {
callback(err);
} else {
callback(undefined, buffer.toString(), {
type: type,
encoding: encoding,
});
}
});
} else {
// uncompressed response
callback(undefined, buffer, {
type: type,
encoding: encoding,
});
}
});
}
})
.on("error", function onError(err) {
callback(err);
});
}

@@ -164,3 +169,3 @@

function callbackYield(callback, err, data, options) {
if (typeof callback === 'function') {
if (typeof callback === "function") {
callback.apply(callback, [err, data].concat(options.args));

@@ -190,50 +195,56 @@ }

pathname: url.resolve(config.pathname, pathname),
query: query
query: query,
});
if (options.dryRun) {
// dry run: return the API url (string) only
if (typeof callback === 'function') {
callback.apply(callback,
[undefined, helper.dryRun(config, pathname)]
);
if (typeof callback === "function") {
callback.apply(callback, [undefined, helper.dryRun(config, pathname)]);
}
} else {
// make the real API call
get.call(this, config, pathname, options.proxy, options.agent, function apiCallback(err, data, info) {
if (!err) {
try {
if (options.parser) {
// async parser
if (options.parser.async) {
return options.parser(data,
asyncParserCallback.bind(callback, options));
get.call(
this,
config,
pathname,
options.proxy,
options.agent,
function apiCallback(err, data, info) {
if (!err) {
try {
if (options.parser) {
// async parser
if (options.parser.async) {
return options.parser(
data,
asyncParserCallback.bind(callback, options)
);
} else {
data = options.parser(data);
}
} else {
data = options.parser(data);
if (!data) {
data = {};
} else if (info.type === "application/json") {
data = JSON.parse(data);
} else if (info.type === "text/xml") {
return helper.xmlToObj(
data,
asyncParserCallback.bind(callback, options)
);
} else if (info.type === "text/html") {
data = { result: (reHTMLOutput.exec(data) || [])[1] };
} else if (info.type === "text/plain") {
data = { result: data.toString() };
}
}
} else {
if (!data) {
data = {};
} else if (info.type === 'application/json') {
data = JSON.parse(data);
} else if (info.type === 'text/xml') {
return helper.xmlToObj(data,
asyncParserCallback.bind(callback, options));
} else if (info.type === 'text/html') {
data = {result: (reHTMLOutput.exec(data) || [])[1]};
} else if (info.type === 'text/plain') {
data = {result: data.toString()};
}
} catch (ex) {
err = ex;
}
} catch (ex) {
err = ex;
}
}
callbackYield(callback, err, data, options);
}.bind(this), options.encoding);
callbackYield(callback, err, data, options);
}.bind(this),
options.encoding
);
}

@@ -252,15 +263,17 @@

// set run and cached with or without defaults
run = parseInt(options.run || options.r, 10) ||
(doNotDefault ? undefined : 1);
cached = (options.repeatView || options.cached || options.c) ?
filenames.cached : '';
run =
parseInt(options.run || options.r, 10) || (doNotDefault ? undefined : 1);
cached =
options.repeatView || options.cached || options.c ? filenames.cached : "";
// when falsy, check set default accordingly
if (doNotDefault && !cached) {
cached = ['repeatView', 'cached', 'c'].some(function(key) {
cached = ["repeatView", "cached", "c"].some(function (key) {
return key in options;
}) ? '' : undefined;
})
? ""
: undefined;
}
if (typeof input === 'string') {
return run + cached + '_' + input;
if (typeof input === "string") {
return run + cached + "_" + input;
} else {

@@ -280,3 +293,3 @@ if (run !== undefined) {

function getTestStatus(id, options, callback) {
var query = {test: id};
var query = { test: id };

@@ -291,5 +304,5 @@ callback = callback || options;

function getTestResults(id, options, callback) {
var query = {test: id};
var query = { test: id };
callback = callback || typeof options === 'function' && options;
callback = callback || (typeof options === "function" && options);
options = options === callback ? {} : helper.deepClone(options) || {};

@@ -300,5 +313,8 @@ helper.setQuery(mapping.commands.results, options, query);

if (options.specs && !options.dryRun) {
return api.call(this, paths.testResults,
return api.call(
this,
paths.testResults,
specs.bind(this, options.specs, options.reporter, callback),
query, options
query,
options
);

@@ -346,8 +362,8 @@ }

options = options === callback ? {} : helper.deepClone(options);
// testing url or script?
query[reSpace.test(what) ? 'script' : 'url'] = what;
query[reSpace.test(what) ? "script" : "url"] = what;
// set dummy url when scripting, needed when webdriver script
if (query.script) {
query.url = 'https://www.webpagetest.org';
query.url = "https://www.webpagetest.org";
}

@@ -358,7 +374,7 @@ helper.setQuery(mapping.commands.test, options, query);

if (reConnectivity.test(options.connectivity) && query.location) {
query.location += ('.' + options.connectivity);
query.location += "." + options.connectivity;
}
// json output format
query.f = 'json';
query.f = "json";

@@ -371,4 +387,8 @@ // API key

// synchronous tests with results
var testId, polling, server, listen, timerout,
resultsOptions = {};
var testId,
polling,
server,
listen,
timerout,
resultsOptions = {};

@@ -387,10 +407,14 @@ function resultsCallback(err, data) {

// and not when specs are done testing
if (!err && (!data || data && data.data &&
data.statusCode !== 200) &&
!(typeof err === 'number' && data === undefined)) {
polling = setTimeout(getTestResults.bind(this, testId,
resultsOptions, poll.bind(this)), options.pollResults);
if (
!err &&
(!data || (data && data.data && data.statusCode !== 200)) &&
!(typeof err === "number" && data === undefined)
) {
polling = setTimeout(
getTestResults.bind(this, testId, resultsOptions, poll.bind(this)),
options.pollResults
);
} else {
if (!data) {
data = {testId: testId};
data = { testId: testId };
}

@@ -424,6 +448,6 @@ resultsCallback(err, data);

error: {
code: 'TIMEOUT',
code: "TIMEOUT",
testId: testId,
message: 'timeout'
}
message: "timeout",
},
});

@@ -434,6 +458,6 @@ }

query.pingback = url.format({
protocol: 'http',
protocol: "http",
hostname: options.waitResults.hostname,
port: options.waitResults.port,
pathname: '/testdone'
pathname: "/testdone",
});

@@ -457,3 +481,3 @@

var name = mapping.options.results[key].name,
value = options[name] || options[key];
value = options[name] || options[key];

@@ -469,4 +493,9 @@ if (value !== undefined) {

return api.call(this, paths.test, testCallback.bind(this, poll),
query, options);
return api.call(
this,
paths.test,
testCallback.bind(this, poll),
query,
options
);
}

@@ -476,30 +505,42 @@

if (options.waitResults && !options.dryRun) {
options.waitResults = helper.localhost(
options.waitResults,
WebPageTest.defaultWaitResultsPort
);
options.waitResults = helper.localhost(options.waitResults,
WebPageTest.defaultWaitResultsPort);
listen = listener.bind(this);
server = http.createServer(function(req, res) {
var uri = url.parse(req.url, true);
server = http.createServer(
function (req, res) {
var uri = url.parse(req.url, true);
res.statusCode = 204;
res.end();
res.statusCode = 204;
res.end();
if (uri.pathname === '/testdone' && uri.query.id === testId) {
server.close(getTestResults.bind(this, uri.query.id,
resultsOptions, resultsCallback));
}
}.bind(this));
if (uri.pathname === "/testdone" && uri.query.id === testId) {
server.close(
getTestResults.bind(
this,
uri.query.id,
resultsOptions,
resultsCallback
)
);
}
}.bind(this)
);
server.on('error', function(err) {
if (['EACCES', 'EADDRINUSE'].indexOf(err.code) > -1) {
// remove old unused listener and bump port for next attempt
server.removeListener('listening', listen);
options.waitResults.port++;
wait.call(this);
} else {
callback(err);
}
}.bind(this));
server.on(
"error",
function (err) {
if (["EACCES", "EADDRINUSE"].indexOf(err.code) > -1) {
// remove old unused listener and bump port for next attempt
server.removeListener("listening", listen);
options.waitResults.port++;
wait.call(this);
} else {
callback(err);
}
}.bind(this)
);

@@ -513,3 +554,3 @@ return wait.call(this);

function restartTest(id, options, callback) {
var query = {resubmit: id};
var query = { resubmit: id };

@@ -525,3 +566,3 @@ callback = callback || options;

function cancelTest(id, options, callback) {
var query = {test: id};
var query = { test: id };

@@ -540,6 +581,12 @@ callback = callback || options;

return api.call(this, paths.gzip, callback, {
test: id,
file: setFilename(filenames.pageSpeed, options)
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: setFilename(filenames.pageSpeed, options),
},
options
);
}

@@ -551,3 +598,3 @@

return api.call(this, paths.har, callback, {test: id}, options);
return api.call(this, paths.har, callback, { test: id }, options);
}

@@ -560,6 +607,12 @@

return api.call(this, paths.gzip, callback, {
test: id,
file: setFilename(filenames.utilization, options)
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: setFilename(filenames.utilization, options),
},
options
);
}

@@ -571,19 +624,87 @@

options.parser = options.parser || helper.tsvToObj.bind(null, [
'', '', '', 'ip_addr', 'method', 'host', 'url', 'responseCode', 'load_ms',
'ttfb_ms', 'load_start', 'bytesOut', 'bytesIn', 'objectSize', '', '',
'expires', 'cacheControl', 'contentType', 'contentEncoding', 'type',
'socket', '', '', '', '', '', '', '', '', '', '', '', '', '',
'score_cache', 'score_cdn', 'score_gzip', 'score_cookies',
'score_keep-alive', '', 'score_minify', 'score_combine', 'score_compress',
'score_etags', '', 'is_secure', 'dns_ms', 'connect_ms', 'ssl_ms',
'gzip_total', 'gzip_save', 'minify_total', 'minify_save', 'image_total',
'image_save', 'cache_time', '', '', '', 'cdn_provider', 'dns_start',
'dns_end', 'connect_start', 'connect_end', 'ssl_start', 'ssl_end',
'initiator', 'initiator_line', 'initiator_column']);
options.parser =
options.parser ||
helper.tsvToObj.bind(null, [
"",
"",
"",
"ip_addr",
"method",
"host",
"url",
"responseCode",
"load_ms",
"ttfb_ms",
"load_start",
"bytesOut",
"bytesIn",
"objectSize",
"",
"",
"expires",
"cacheControl",
"contentType",
"contentEncoding",
"type",
"socket",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"score_cache",
"score_cdn",
"score_gzip",
"score_cookies",
"score_keep-alive",
"",
"score_minify",
"score_combine",
"score_compress",
"score_etags",
"",
"is_secure",
"dns_ms",
"connect_ms",
"ssl_ms",
"gzip_total",
"gzip_save",
"minify_total",
"minify_save",
"image_total",
"image_save",
"cache_time",
"",
"",
"",
"cdn_provider",
"dns_start",
"dns_end",
"connect_start",
"connect_end",
"ssl_start",
"ssl_end",
"initiator",
"initiator_line",
"initiator_column",
]);
return api.call(this, paths.gzip, callback, {
test: id,
file: setFilename(filenames.request, options)
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: setFilename(filenames.request, options),
},
options
);
}

@@ -596,3 +717,3 @@

options = options === callback ? undefined : options;
query = setFilename({test: id}, options, true);
query = setFilename({ test: id }, options, true);

@@ -607,6 +728,12 @@ return api.call(this, paths.timeline, callback, query, options);

return api.call(this, paths.gzip, callback, {
test: id,
file: setFilename(filenames.netLog, options)
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: setFilename(filenames.netLog, options),
},
options
);
}

@@ -619,6 +746,12 @@

return api.call(this, paths.gzip, callback, {
test: id,
file: setFilename(filenames.chromeTrace, options)
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: setFilename(filenames.chromeTrace, options),
},
options
);
}

@@ -631,6 +764,12 @@

return api.call(this, paths.gzip, callback, {
test: id,
file: setFilename(filenames.consoleLog, options)
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: setFilename(filenames.consoleLog, options),
},
options
);
}

@@ -643,6 +782,12 @@

return api.call(this, paths.gzip, callback, {
test: id,
file: filenames.testInfo
}, options);
return api.call(
this,
paths.gzip,
callback,
{
test: id,
file: filenames.testInfo,
},
options
);
}

@@ -657,5 +802,5 @@

query = {
all: 'on',
f: 'csv',
days: days ? parseInt(days, 10) : 1
all: "on",
f: "csv",
days: days ? parseInt(days, 10) : 1,
};

@@ -672,3 +817,3 @@

options.parser = options.parser || helper.csvParser;
query = setFilename({test: id}, options, true);
query = setFilename({ test: id }, options, true);

@@ -684,5 +829,5 @@ return api.call(this, paths.googleCsi, callback, query, options);

options.args = options.args || {
type: 'text/plain'
type: "text/plain",
};
query = setFilename({test: id}, options);
query = setFilename({ test: id }, options);
query.request = options.request || 1;

@@ -695,14 +840,14 @@

var query,
pathname = paths.waterfall;
pathname = paths.waterfall;
callback = callback || options;
options = options === callback ? {} : options;
query = setFilename({test: id}, options),
options.encoding = options.encoding || 'binary';
(query = setFilename({ test: id }, options)),
(options.encoding = options.encoding || "binary");
options.dataURI = options.dataURI || options.uri || options.u;
options.parser = options.parser ||
(options.dataURI ? helper.dataURI : undefined);
options.parser =
options.parser || (options.dataURI ? helper.dataURI : undefined);
options.args = options.args || {
type: 'image/png',
encoding: options.dataURI ? 'utf8' : options.encoding
type: "image/png",
encoding: options.dataURI ? "utf8" : options.encoding,
};

@@ -722,12 +867,12 @@

var pathname = paths.gzip,
filename = filenames.screenshot,
params = {test: id},
type = 'jpeg';
filename = filenames.screenshot,
params = { test: id },
type = "jpeg";
callback = callback || options;
options = options === callback ? {} : options;
options.encoding = options.encoding || 'binary';
options.encoding = options.encoding || "binary";
options.dataURI = options.dataURI || options.uri || options.u;
options.parser = options.parser ||
(options.dataURI ? helper.dataURI : undefined);
options.parser =
options.parser || (options.dataURI ? helper.dataURI : undefined);

@@ -740,7 +885,7 @@ if (options.startRender || options.render || options.n) {

filename = filenames.screenshotFullResolution;
type = 'png';
type = "png";
}
options.args = options.args || {
type: 'image/' + type,
encoding: options.dataURI ? 'utf8' : options.encoding
type: "image/" + type,
encoding: options.dataURI ? "utf8" : options.encoding,
};

@@ -769,8 +914,8 @@

embed: 1,
id: id
id: id,
};
options.args = options.args || {
type: 'text/html',
encoding: options.dataURI ? 'utf8' : options.encoding
type: "text/html",
encoding: options.dataURI ? "utf8" : options.encoding,
};

@@ -789,4 +934,4 @@

tests: tests,
f: 'json',
end: options.comparisonEndPoint || 'visual'
f: "json",
end: options.comparisonEndPoint || "visual",
};

@@ -810,3 +955,3 @@

WebPageTest.filenames = filenames;
WebPageTest.defaultServer = 'https://www.webpagetest.org';
WebPageTest.defaultServer = "https://www.webpagetest.org";
WebPageTest.defaultListenPort = 7791;

@@ -816,4 +961,4 @@ WebPageTest.defaultWaitResultsPort = 8000;

// Version
Object.defineProperty(WebPageTest, 'version', {
value: require('../package.json').version
Object.defineProperty(WebPageTest, "version", {
value: require("../package.json").version,
});

@@ -834,3 +979,3 @@

getPageSpeedData: getPageSpeedData,
getTestBalance : getTestBalance,
getTestBalance: getTestBalance,
getHARData: getHARData,

@@ -876,5 +1021,5 @@ getUtilizationData: getUtilizationData,

waterfall: getWaterfallImage,
screenshot: getScreenshotImage
screenshot: getScreenshotImage,
};
module.exports = WebPageTest;
{
"name": "webpagetest",
"version": "0.5.1",
"version": "0.6.0",
"description": "WebPageTest API wrapper for NodeJS",

@@ -23,3 +23,5 @@ "author": "WebPageTest <github@WebPageTest.com> (http://github.com/WebPageTest)",

"main": "lib/webpagetest.js",
"bin": "bin/webpagetest",
"bin": {
"webpagetest": "bin/webpagetest"
},
"scripts": {

@@ -26,0 +28,0 @@ "test": "./node_modules/mocha/bin/mocha -R spec test/*-test.js"

@@ -12,3 +12,2 @@ <p align="center"><img src="https://docs.webpagetest.org/img/wpt-navy-logo.png" alt="WebPageTest Logo" /></p>

## Getting started

@@ -23,2 +22,3 @@

### Command line
```bash

@@ -29,7 +29,11 @@ $ webpagetest test https://docs.webpagetest.org/api/integrations/

### Docker
#### Build
```bash
$ docker build -t webpagetest-api .
```
#### Run
```bash

@@ -40,7 +44,8 @@ $ docker run -it --rm webpagetest-api -k YOURAPIKEY test https://docs.webpagetest.org/api/integrations/

### Module
```javascript
const WebPageTest = require('webpagetest');
const wpt = new WebPageTest('www.webpagetest.org');
const WebPageTest = require("webpagetest");
const wpt = new WebPageTest("www.webpagetest.org");
wpt.runTest('https://docs.webpagetest.org/api/integrations/', (err, data) => {
wpt.runTest("https://docs.webpagetest.org/api/integrations/", (err, data) => {
console.log(err || data);

@@ -53,2 +58,3 @@ });

### Help
```bash

@@ -59,168 +65,184 @@ $ webpagetest --help

### Commands
* **status** _[options] \<id\>_: check test status
* **results** _[options] \<id\>_: get test results
* **locations** _[options]_: list locations and the number of pending tests
* **testers** _[options]_: list testers status and details
* **test** _[options] \<url_or_script\>_: run test, _\<url_or_script\>_ can also be a path to a script file
* **testBalance** _[options]_: get remaining tests for the account
* **restart** _\<id\>_: restart test
* **cancel** _\<id\>_: cancel running/pending test
* **har** _\<id\>_: get the HTTP Archive (HAR) from test
* **pagespeed** _[options] \<id\>_: get the Google Page Speed results (if available) from test
* **utilization** _[options] \<id\>_: get the CPU, bandwidth and memory utilization data from test
* **request** _[options] <\id\>_: get the request data from test
* **timeline** _[options] \<id\>_: get the Chrome Developer Tools Timeline data (if available) from test
* **netlog** _[options] \<id\>_: get the Chrome Developer Tools Net log data (if available) from test
* **chrometrace** _[options] \<id\>_: get the Chrome Trace data (if available) from test
* **console** _[options] \<id\>_: get the browser console log data (if available) from test
* **testinfo** _\<id\>_: get test request info/details
* **history** _[days]_: get history of previously run tests
* **googlecsi** _[options] \<id\>_: get Google CSI data (Client Side Instrumentation)
* **response** _[options] \<id\>_: get response body for text resources
* **waterfall** _[options] \<id\>_: get the waterfall PNG image
* **screenshot** _[options] \<id\>_: get the fully loaded page screenshot in JPG format (PNG if in full resolution)
* **video** _[options] \<tests\>_: create a video from _\<tests\>_ (comma separated test ids)
* **player** _\<id\>_: get a html5 player for a video _\<id\>_
* **listen** _[options]_ _[port]_: start webpagetest-api server on port _[7791_]
* **batch** _\<file\>_: run commands in batch, i.e. one command per line from _\<file\>_ in parallel
- **status** _[options] \<id\>_: check test status
- **results** _[options] \<id\>_: get test results
- **locations** _[options]_: list locations and the number of pending tests
- **testers** _[options]_: list testers status and details
- **test** _[options] \<url_or_script\>_: run test, _\<url_or_script\>_ can also be a path to a script file
- **testBalance** _[options]_: get remaining tests for the account
- **restart** _\<id\>_: restart test
- **cancel** _\<id\>_: cancel running/pending test
- **har** _\<id\>_: get the HTTP Archive (HAR) from test
- **pagespeed** _[options] \<id\>_: get the Google Page Speed results (if available) from test
- **utilization** _[options] \<id\>_: get the CPU, bandwidth and memory utilization data from test
- **request** _[options] <\id\>_: get the request data from test
- **timeline** _[options] \<id\>_: get the Chrome Developer Tools Timeline data (if available) from test
- **netlog** _[options] \<id\>_: get the Chrome Developer Tools Net log data (if available) from test
- **chrometrace** _[options] \<id\>_: get the Chrome Trace data (if available) from test
- **console** _[options] \<id\>_: get the browser console log data (if available) from test
- **testinfo** _\<id\>_: get test request info/details
- **history** _[days]_: get history of previously run tests
- **googlecsi** _[options] \<id\>_: get Google CSI data (Client Side Instrumentation)
- **response** _[options] \<id\>_: get response body for text resources
- **waterfall** _[options] \<id\>_: get the waterfall PNG image
- **screenshot** _[options] \<id\>_: get the fully loaded page screenshot in JPG format (PNG if in full resolution)
- **video** _[options] \<tests\>_: create a video from _\<tests\>_ (comma separated test ids)
- **player** _\<id\>_: get a html5 player for a video _\<id\>_
- **listen** _[options]_ _[port]_: start webpagetest-api server on port _[7791_]
- **batch** _\<file\>_: run commands in batch, i.e. one command per line from _\<file\>_ in parallel
### Options
#### Common (works for all commands)
* **-s, --server** _\<server\>_: the WPT server URL [https://www.webpagetest.org]
* **-d, --dryrun**: just return the RESTful API URL
* **-o, --out** _\<file\>_: place the output into \<file\>. Defaults to stdout
- **-s, --server** _\<server\>_: the WPT server URL [https://www.webpagetest.org]
- **-d, --dryrun**: just return the RESTful API URL
- **-o, --out** _\<file\>_: place the output into \<file\>. Defaults to stdout
_The default WPT server can also be specified via environment variable `WEBPAGETEST_SERVER`_
#### Test (works for **test** command only)
* **-l, --location** _\<location\>_: location to test from
* **-y, --connectivity** _\<profile\>_: connectivity profile -- requires location to be specified -- (Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom) [Cable]
* **-r, --runs** _\<number\>_: number of test runs [1]
* **-f, --first**: skip the Repeat View test
* **-v, --video**: capture video
* **-p, --private**: keep the test hidden from the test log
* **-L, --label** _\<label\>_: label for the test
* **-i, --onload**: stop test at document complete. typically, tests run until all activity stops
* **-S, --noscript**: disable javascript (IE, Chrome, Firefox)
* **-C, --clearcerts**: clear SSL certificate caches
* **-R, --ignoressl**: ignore SSL certificate errors, e.g. name mismatch, self-signed certificates, etc
* **-T, --standards**: forces all pages to load in standards mode (IE only)
* **-u, --tcpdump**: capture network packet trace (tcpdump)
* **-O, --bodies**: save response bodies for text resources
* **-K, --keepua**: do not add PTST to the original browser User Agent string
* **-m, --dom** _\<element\>_: DOM element to record for sub-measurement
* **-N, --duration** _\<seconds\>_: minimum test duration in seconds
* **--injectScript** _\<string\>_: JavaScript to run after the document has started loading
* **-E, --tester** _\<name\>_: run the test on a specific PC (name must match exactly or the test will not run)
* **-W, --mobile**: (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only)
* **--device** _\<string\>_: device name from mobile_devices.ini to use for mobile emulation (only when mobile=1 is specified to enable emulation and only for Chrome)
* **-M, --timeline**: capture Developer Tools Timeline (Chrome only)
* **-J, --callstack**: set between 1-5 to include the JS call stack. must be used in conjunction with timeline (increases overhead) (Chrome only)
* **-q, --chrometrace**: capture chrome trace (about://tracing) (Chrome only)
* **--tracecategories** _\<categories>\>_: trace categories (when chrometrace enabled) (Chrome only)
* **-G, --netlog**: capture Network Log (Chrome only)
* **-Q, --datareduction**: enable data reduction on Chrome 34+ Android (Chrome only)
* **-x, --useragent** _\<string\>_: custom user agent string (Chrome only)
* **-X, --cmdline** _\<switches\>_: use a list of custom command line switches (Chrome only)
* **-g, --login** _\<username\>_: username for authenticating tests (http authentication)
* **-w, --password** _\<password\>_: password for authenticating tests (http authentication)
* **-t, --sensitive**: discard script and http headers in the result
* **-H, --noheaders**: disable saving of the http headers (as well as browser status messages and CPU utilization)
* **-b, --block** _\<urls\>_: space-delimited list of urls to block (substring match)
* **-Z, --spof** _\<domains\>_: space-delimited list of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests
* **-c, --custom** _\<script\>_: execute arbitrary javascript at the end of a test to collect custom metrics
* **-a, --authtype** _\<type\>_: type of authentication: 0 = Basic, 1 = SNS [0]
* **-n, --notify** _\<e-mail\>_: e-mail address to notify with the test results
* **-B, --pingback** _\<url\>_: URL to ping when the test is complete (the test ID will be passed as an "id" parameter)
* **-D, --bwdown** _\<bandwidth\>_: download bandwidth in Kbps (used when specifying a custom connectivity profile)
* **-U, --bwup** _\<bandwidth\>_: upload bandwidth in Kbps (used when specifying a custom connectivity profile)
* **-bw, --browserwidth** _\<pixels\>_: Browser window width (in display pixels)
* **-bh, --browserheight** _\<pixels\>_: Browser window height (in display pixels)
* **-vh, --viewportheight** _\<pixels\>_: Viewport Height in css pixels
* **-vw, --viewportwidth** _\<pixels\>_: Viewport Width in css pixels
* **-dpr, --devicetopixelratio** _\<ratio\>_: Device To Pixel Ratio
* **-au, --appendua** _\<string\>_: String to append to the user agent string. This is in addition to the default PTST/ver string
* **-tt, --testtype** _\<string\>_: For running alternative test types, can specify traceroute or lighthouse
* **-pr, --profiler** _\<number\>_: Set to 1 to enable the V8 sampling profiler (Chromium only)
* **-avif, --disableAVIF** _\<number\>_: Set to 1 to disable AVIF support (Chromium 88+)
* **-webp, --disableWEBP** _\<number\>_: Set to 1 to disable WEBP support (Chromium 88+)
* **-jxl, --disableJXL** _\<number\>_: Set to 1 to disable JXL support (Chromium 88+)
* **-dts, --dtShaper** _\<number\>_: Set to 1 to use Chrome's built-in traffic-shaping instead of the packet-level netem shaping usually used by the test agents
* **-Y, --latency** _\<time\>_: first-hop Round Trip Time in ms (used when specifying a custom connectivity profile)
* **-P, --plr** _\<percentage\>_: packet loss rate - percent of packets to drop (used when specifying a custom connectivity profile)
* **-z, --noopt**: disable optimization checks (for faster testing)
* **-I, --noimages**: disable screen shot capturing
* **-F, --full**: save a full-resolution version of the fully loaded screen shot as a PNG
* **-j, --jpeg** _\<level\>_: jpeg compression level (30-100) for the screen shots and video capture
* **-A, --medianvideo**: store the video from the median run when capturing video is enabled
* **--htmlbody**: save the content of only the base HTML response
* **--tsview** _\<id\>_: test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
* **--tsviewconfigs** _\<string\>_: configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
* **--affinity** _\<string\>_: string to hash test to a specific test agent. tester will be picked by index among available testers
* **--priority** _\<number\>_: change test priority (0-9) [enforced by API key, otherwise 5]
* **--continuous**: capture video continuously (unstable/experimental, may cause tests to fail)
* **--spdy3**: force SPDY version 3 (Chrome only)
* **--swrender**: force software rendering, disable GPU acceleration (Chrome only)
* **--poll** _\<interval\>_: poll for results after test is scheduled at every <interval> seconds [5]
* **--wait** _\<hostname:port\>_: wait for test results informed by agent once complete listening on <hostname>:<port> [hostname:first port available above 8000]
* **--timeout** _\<seconds\>_: timeout for polling and waiting results [no timeout]
* **--lighthouse**: perform lighthouse test (Chrome only, Linux agent only)
- **-l, --location** _\<location\>_: location to test from
- **-y, --connectivity** _\<profile\>_: connectivity profile -- requires location to be specified -- (Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom) [Cable]
- **-r, --runs** _\<number\>_: number of test runs [1]
- **-f, --first**: skip the Repeat View test
- **-v, --video**: capture video
- **-p, --private**: keep the test hidden from the test log
- **-L, --label** _\<label\>_: label for the test
- **-i, --onload**: stop test at document complete. typically, tests run until all activity stops
- **-S, --noscript**: disable javascript (IE, Chrome, Firefox)
- **-C, --clearcerts**: clear SSL certificate caches
- **-R, --ignoressl**: ignore SSL certificate errors, e.g. name mismatch, self-signed certificates, etc
- **-T, --standards**: forces all pages to load in standards mode (IE only)
- **-u, --tcpdump**: capture network packet trace (tcpdump)
- **-O, --bodies**: save response bodies for text resources
- **-K, --keepua**: do not add PTST to the original browser User Agent string
- **-m, --dom** _\<element\>_: DOM element to record for sub-measurement
- **-N, --duration** _\<seconds\>_: minimum test duration in seconds
- **--injectScript** _\<string\>_: JavaScript to run after the document has started loading
- **-E, --tester** _\<name\>_: run the test on a specific PC (name must match exactly or the test will not run)
- **-W, --mobile**: (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only)
- **--device** _\<string\>_: device name from mobile_devices.ini to use for mobile emulation (only when mobile=1 is specified to enable emulation and only for Chrome)
- **-M, --timeline**: capture Developer Tools Timeline (Chrome only)
- **-J, --callstack**: set between 1-5 to include the JS call stack. must be used in conjunction with timeline (increases overhead) (Chrome only)
- **-q, --chrometrace**: capture chrome trace (about://tracing) (Chrome only)
- **--tracecategories** _\<categories>\>_: trace categories (when chrometrace enabled) (Chrome only)
- **-G, --netlog**: capture Network Log (Chrome only)
- **-Q, --datareduction**: enable data reduction on Chrome 34+ Android (Chrome only)
- **-x, --useragent** _\<string\>_: custom user agent string (Chrome only)
- **-X, --cmdline** _\<switches\>_: use a list of custom command line switches (Chrome only)
- **-g, --login** _\<username\>_: username for authenticating tests (http authentication)
- **-w, --password** _\<password\>_: password for authenticating tests (http authentication)
- **-t, --sensitive**: discard script and http headers in the result
- **-H, --noheaders**: disable saving of the http headers (as well as browser status messages and CPU utilization)
- **-b, --block** _\<urls\>_: space-delimited list of urls to block (substring match)
- **-Z, --spof** _\<domains\>_: space-delimited list of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests
- **-c, --custom** _\<script\>_: execute arbitrary javascript at the end of a test to collect custom metrics
- **-a, --authtype** _\<type\>_: type of authentication: 0 = Basic, 1 = SNS [0]
- **-n, --notify** _\<e-mail\>_: e-mail address to notify with the test results
- **-B, --pingback** _\<url\>_: URL to ping when the test is complete (the test ID will be passed as an "id" parameter)
- **-D, --bwdown** _\<bandwidth\>_: download bandwidth in Kbps (used when specifying a custom connectivity profile)
- **-U, --bwup** _\<bandwidth\>_: upload bandwidth in Kbps (used when specifying a custom connectivity profile)
- **-bw, --browserwidth** _\<pixels\>_: Browser window width (in display pixels)
- **-bh, --browserheight** _\<pixels\>_: Browser window height (in display pixels)
- **-vh, --viewportheight** _\<pixels\>_: Viewport Height in css pixels
- **-vw, --viewportwidth** _\<pixels\>_: Viewport Width in css pixels
- **-dpr, --devicetopixelratio** _\<ratio\>_: Device To Pixel Ratio
- **-au, --appendua** _\<string\>_: String to append to the user agent string. This is in addition to the default PTST/ver string
- **-tt, --testtype** _\<string\>_: For running alternative test types, can specify traceroute or lighthouse
- **-pr, --profiler** _\<number\>_: Set to 1 to enable the V8 sampling profiler (Chromium only)
- **-avif, --disableAVIF** _\<number\>_: Set to 1 to disable AVIF support (Chromium 88+)
- **-webp, --disableWEBP** _\<number\>_: Set to 1 to disable WEBP support (Chromium 88+)
- **-jxl, --disableJXL** _\<number\>_: Set to 1 to disable JXL support (Chromium 88+)
- **-dts, --dtShaper** _\<number\>_: Set to 1 to use Chrome's built-in traffic-shaping instead of the packet-level netem shaping usually used by the test agents
- **-Y, --latency** _\<time\>_: first-hop Round Trip Time in ms (used when specifying a custom connectivity profile)
- **-P, --plr** _\<percentage\>_: packet loss rate - percent of packets to drop (used when specifying a custom connectivity profile)
- **-z, --noopt**: disable optimization checks (for faster testing)
- **-I, --noimages**: disable screen shot capturing
- **-F, --full**: save a full-resolution version of the fully loaded screen shot as a PNG
- **-j, --jpeg** _\<level\>_: jpeg compression level (30-100) for the screen shots and video capture
- **-A, --medianvideo**: store the video from the median run when capturing video is enabled
- **--htmlbody**: save the content of only the base HTML response
- **--tsview** _\<id\>_: test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
- **--tsviewconfigs** _\<string\>_: configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
- **--affinity** _\<string\>_: string to hash test to a specific test agent. tester will be picked by index among available testers
- **--priority** _\<number\>_: change test priority (0-9) [enforced by API key, otherwise 5]
- **--continuous**: capture video continuously (unstable/experimental, may cause tests to fail)
- **--spdy3**: force SPDY version 3 (Chrome only)
- **--swrender**: force software rendering, disable GPU acceleration (Chrome only)
- **--poll** _\<interval\>_: poll for results after test is scheduled at every <interval> seconds [5]
- **--wait** _\<hostname:port\>_: wait for test results informed by agent once complete listening on <hostname>:<port> [hostname:first port available above 8000]
- **--timeout** _\<seconds\>_: timeout for polling and waiting results [no timeout]
- **--lighthouse**: perform lighthouse test (Chrome only, Linux agent only)
- **-thc, --throttleCPU** _\<number\>_: custom cpu throttle
#### API Key (works for **test**, **restart**,**locations**, **testBalance** and **cancel** commands)
* **-k, --key** _\<api_key\>_:API key (if assigned). Contact the WebPageTest server administrator for a key if required or request an API key for limited testing at [webpagetest.org/getkey.php](https://www.webpagetest.org/getkey.php)
- **-k, --key** _\<api_key\>_:API key (if assigned). Contact the WebPageTest server administrator for a key if required or request an API key for limited testing at [webpagetest.org/getkey.php](https://www.webpagetest.org/getkey.php)
#### Request (works for **status**, **results**, **locations**, **testers** and **test** commands)
* **-e, --request** _\<id\>_: echo request ID, useful to track asynchronous requests
- **-e, --request** _\<id\>_: echo request ID, useful to track asynchronous requests
#### Results (works for **results** and **test** commands)
* **-b, --breakdown**: include the breakdown of requests and bytes by mime type
* **-D, --domains**: include the breakdown of requests and bytes by domain
* **-p, --pagespeed**: include the PageSpeed score in the response (may be slower)
* **-R, --requests**: include the request data in the response (slower and results in much larger responses)
* **-m, --median** _\<metric\>_: set the metric used to calculate median for multiple runs tests [loadTime]
* **--medianrun** _\<metric>_: set the run used for median for multiple runs tests [median]
* **-S, --specs** _\<json_or_file\>_: set the specs for performance test suite
* **-r, --reporter** _\<name\>_: set performance test suite reporter output: [dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity
- **-b, --breakdown**: include the breakdown of requests and bytes by mime type
- **-D, --domains**: include the breakdown of requests and bytes by domain
- **-p, --pagespeed**: include the PageSpeed score in the response (may be slower)
- **-R, --requests**: include the request data in the response (slower and results in much larger responses)
- **-m, --median** _\<metric\>_: set the metric used to calculate median for multiple runs tests [loadTime]
- **--medianrun** _\<metric>_: set the run used for median for multiple runs tests [median]
- **-S, --specs** _\<json_or_file\>_: set the specs for performance test suite
- **-r, --reporter** _\<name\>_: set performance test suite reporter output: [dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity
#### Run (works for **pagespeed**, **utilization**, **request**, **timeline**, **netlog**, **chrometrace**, **console**, **googlecsi**, **response**, **waterfall** and **screenshot** commands)
* **-r, --run** _\<number\>_: which run number on a multiple runs test [1]
* **-c, --cached**: get the Repeat View (cached view) instead of default First View (primed cache)
- **-r, --run** _\<number\>_: which run number on a multiple runs test [1]
- **-c, --cached**: get the Repeat View (cached view) instead of default First View (primed cache)
#### Image (works for **waterfall** and **screenshot** commands)
* **-t, --thumbnail**: get the thumbnail of actual image
* **-u, --uri**: return the base64 string representation (inline) of actual image
- **-t, --thumbnail**: get the thumbnail of actual image
- **-u, --uri**: return the base64 string representation (inline) of actual image
#### Screenshot (works for **screenshot** command only)
* **-f, --full**: get full resolution screenshot in PNG format if available
* **-n, --render**: get the page screenshot at the Start Render point (i.e.: when something was first displayed on screen)
* **-p, --complete**: get the page screenshot at the Document Complete point (i.e.: when window.onload was fired)
- **-f, --full**: get full resolution screenshot in PNG format if available
- **-n, --render**: get the page screenshot at the Start Render point (i.e.: when something was first displayed on screen)
- **-p, --complete**: get the page screenshot at the Document Complete point (i.e.: when window.onload was fired)
#### Waterfall (works for **waterfall** command only)
* **-T, --type** _\<chart\>_: set the chart type: waterfall or connection [waterfall]
* **-M, --mime**: set chart coloring by MIME type [false]
* **-w, --width** _\<px\>_: chart image width in px (300-2000) [930]
* **-m, --max** _\<seconds\>_: set maximum time in seconds [automatic]
* **-R, --requests** _\<items\>_: filter requests (e.g.:1,2,3,4-9,8) [all]
* **-C, --nocpu**: hide CPU utilization [false]
* **-b, --nobandwidth**: hide bandwidth utilization [false]
* **-e, --noellipsis**: hide ellipsis (...) for missing items [false]
* **-l, --nolabels**: hide labels for requests (URL) [false]
- **-T, --type** _\<chart\>_: set the chart type: waterfall or connection [waterfall]
- **-M, --mime**: set chart coloring by MIME type [false]
- **-w, --width** _\<px\>_: chart image width in px (300-2000) [930]
- **-m, --max** _\<seconds\>_: set maximum time in seconds [automatic]
- **-R, --requests** _\<items\>_: filter requests (e.g.:1,2,3,4-9,8) [all]
- **-C, --nocpu**: hide CPU utilization [false]
- **-b, --nobandwidth**: hide bandwidth utilization [false]
- **-e, --noellipsis**: hide ellipsis (...) for missing items [false]
- **-l, --nolabels**: hide labels for requests (URL) [false]
#### Video (works for **video** command only)
* **-e, --end** _\<end_point\>_: frame comparison end point: [visual]=visually complete | all=last change | doc=document complete | full=fully loaded
- **-e, --end** _\<end_point\>_: frame comparison end point: [visual]=visually complete | all=last change | doc=document complete | full=fully loaded
#### Response (works for **response** command only)
* **-R, --request** _\<number\>_: the request number [1]
- **-R, --request** _\<number\>_: the request number [1]
#### Listen (works for **listen** command only)
* **-k, --key** _\<file\>_: private key file to use for SSL
* **-c, --cert** _\<file\>_: public x509 certificate file to use for SSL
- **-k, --key** _\<file\>_: private key file to use for SSL
- **-c, --cert** _\<file\>_: public x509 certificate file to use for SSL
### Examples
#### 1. Get all available locations
```bash
$ webpagetest locations
```
```javascript

@@ -250,6 +272,9 @@ {

```
#### 2. Get API available locations
```bash
$ webpagetest locations --key 1F2A3K4E5
```
```javascript

@@ -281,5 +306,7 @@ {

#### 3. Run test on https://docs.webpagetest.org/api/integrations/ from San Jose on IE9
```bash
$ webpagetest test https://docs.webpagetest.org/api/integrations/ --key 1F2A3K4E5 --location SanJose_IE9
```
```javascript

@@ -302,5 +329,7 @@ {

#### 4. Check current test status
```bash
$ webpagetest status 121025_PT_N8K
```
```javascript

@@ -322,5 +351,7 @@ {

#### 5. Get test results
```bash
$ webpagetest results 121025_PT_N8K
```
```javascript

@@ -356,5 +387,7 @@ {

#### 6. Get test waterfall thumbnail from repeat view as data URI
```bash
$ webpagetest waterfall 121025_PT_N8K --thumbnail --cached --uri
```
```javascript

@@ -368,5 +401,7 @@ {

#### 7. Get remaining tests count for the account
```bash
$ webpagetest testBalance --key 1F2A3K4E5
```
```javascript

@@ -381,9 +416,13 @@ {

#### Run test on https://docs.webpagetest.org/api/integrations/ and poll results every 5 seconds timing out in 60 seconds
```bash
$ webpagetest test https://docs.webpagetest.org/api/integrations/ --poll 5 --timeout 60
```
#### Or run test on https://docs.webpagetest.org/api/integrations/ and wait for results listening on localhost\* port 8000\**
#### Or run test on https://docs.webpagetest.org/api/integrations/ and wait for results listening on localhost\* port 8000\*\*
```bash
$ webpagetest test https://docs.webpagetest.org/api/integrations/ --wait 8000
```
```javascript

@@ -409,44 +448,48 @@ {

```
_\* hostname and port are optional, defaults to \<system hostname\>:\<8000\>_
_\** localhost and port must be reacheable from WebPageTest server_
_\*\* localhost and port must be reacheable from WebPageTest server_
## Module
Methods and options (including the one letter shorthands) are the same when using as a Node module, however a more verbose version of both commands (methods) and options (parameters) are available and encouraged to use for code clarity.
### Methods
* `getTestStatus(id, options, callback)`
* `getTestResults(id, options, callback)`
* `getLocations(options, callback)`
* `getTesters(options, callback)`
* `getTestBalance(options, callback)`
* `runTest(url_or_script, options, callback)`
* `restartTest(id, options, callback)`
* `cancelTest(id, options, callback)`
* `getHARData(id, options, callback)`
* `getPageSpeedData(id, options, callback)`
* `getUtilizationData(id, options, callback)`
* `getRequestData(id, options, callback)`
* `getTimelineData(id, options, callback)`
* `getNetLogData(id, options, callback)`
* `getChromeTraceData(id, options, callback)`
* `getConsoleLogData(id, options, callback)`
* `getTestInfo(id, options, callback)`
* `getHistory(days, options, callback)`
* `getGoogleCsiData(id, options, callback)`
* `getResponseBody(id, options, callback)`
* `getWaterfallImage(id, options, callback)`
* `getScreenshotImage(id, options, callback)`
* `createVideo(tests, options, callback)`
* `getEmbedVideoPlayer(id, options, callback)`
* `listen(port, options, callback)`
* `scriptToString(script)`
- `getTestStatus(id, options, callback)`
- `getTestResults(id, options, callback)`
- `getLocations(options, callback)`
- `getTesters(options, callback)`
- `getTestBalance(options, callback)`
- `runTest(url_or_script, options, callback)`
- `restartTest(id, options, callback)`
- `cancelTest(id, options, callback)`
- `getHARData(id, options, callback)`
- `getPageSpeedData(id, options, callback)`
- `getUtilizationData(id, options, callback)`
- `getRequestData(id, options, callback)`
- `getTimelineData(id, options, callback)`
- `getNetLogData(id, options, callback)`
- `getChromeTraceData(id, options, callback)`
- `getConsoleLogData(id, options, callback)`
- `getTestInfo(id, options, callback)`
- `getHistory(days, options, callback)`
- `getGoogleCsiData(id, options, callback)`
- `getResponseBody(id, options, callback)`
- `getWaterfallImage(id, options, callback)`
- `getScreenshotImage(id, options, callback)`
- `createVideo(tests, options, callback)`
- `getEmbedVideoPlayer(id, options, callback)`
- `listen(port, options, callback)`
- `scriptToString(script)`
### Parameters
* **id**: test ID string _required_
* **options**: parameters object _optional_, see below
* **callback**: the callback `(error, data)` _optional=> _
* **url_or_script**: decoded url or script string _required_
* **port**: port number _optional_ \[default: 7791\]
* **script**: script array in the format:
- **id**: test ID string _required_
- **options**: parameters object _optional_, see below
- **callback**: the callback `(error, data)` _optional=> _
- **url_or_script**: decoded url or script string _required_
- **port**: port number _optional_ \[default: 7791\]
- **script**: script array in the format:
```javascript

@@ -464,14 +507,14 @@ [

* `getWaterfallImage` and `getScreenshotImage` callback function has a third parameter `info` which is an object with `{type: 'image/jpeg or png', encoding: 'utf8 or binary'}`
* `scriptToString` script array values 1-N are optional. e.g:
- `getWaterfallImage` and `getScreenshotImage` callback function has a third parameter `info` which is an object with `{type: 'image/jpeg or png', encoding: 'utf8 or binary'}`
- `scriptToString` script array values 1-N are optional. e.g:
```javascript
const script = wpt.scriptToString([
{logData: 0},
{navigate: 'http://foo.com/login'},
{logData: 1},
{setValue: ['name=username', 'johndoe']},
{setValue: ['name=password', '12345']},
{submitForm: 'action=http://foo.com/main'},
'waitForComplete'
{ logData: 0 },
{ navigate: "http://foo.com/login" },
{ logData: 1 },
{ setValue: ["name=username", "johndoe"] },
{ setValue: ["name=password", "12345"] },
{ submitForm: "action=http://foo.com/main" },
"waitForComplete",
]);

@@ -485,141 +528,158 @@

### Options
#### Common (works for all methods with `options` parameter)
* **dryRun**: _Boolean_, if `true`, method does not make an actual request to the API Server but rather returns an object with `url` which contains the actual URL to make the GET request to WebPageTest API Server
* **server**: _String_, if specified, overrides the WebPageTest server informed in the constructor only for that method call
- **dryRun**: _Boolean_, if `true`, method does not make an actual request to the API Server but rather returns an object with `url` which contains the actual URL to make the GET request to WebPageTest API Server
- **server**: _String_, if specified, overrides the WebPageTest server informed in the constructor only for that method call
#### Test (works for `runTest` method only)
* **location**: _String_, location to test from
* **connectivity**: _String_, connectivity profile -- requires location to be specified -- (Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom) [Cable]
* **runs**: _Number_, number of test runs [1]
* **firstViewOnly**: _Boolean_, skip the Repeat View test
* **video**: _Boolean_, capture video
* **private**: _Boolean_, keep the test hidden from the test log
* **label**: _String_, label for the test
* **stopAtDocumentComplete**: _Boolean_, stop test at document complete. typically, tests run until all activity stops
* **disableJavaScript**: _Boolean_, disable JavaScript (IE, Chrome, Firefox)
* **clearCerts**: _Boolean_, clear SSL certificate caches
* **ignoreSSL**: _Boolean_, ignore SSL certificate errors, e.g. name mismatch, self-signed certificates, etc
* **disableCompatibilityView**: _Boolean_, forces all pages to load in standards mode (IE only)
* **tcpDump**: _Boolean_, capture network packet trace (tcpdump)
* **saveResponseBodies**: _Boolean_, save response bodies for text resources
* **keepOriginalUserAgent**: _Boolean_, do not add PTST to the original browser User Agent string
* **domElement**: _String_, DOM element to record for sub-measurement
* **minimumDuration**: _Number_, minimum test duration in seconds
* **tester**: _String_, run the test on a specific PC (name must match exactly or the test will not run)
* **emulateMobile**: _Boolean_, (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only)
* **timeline**: _Boolean_, capture Developer Tools Timeline (Chrome only)
* **timelineCallStack**: _Boolean_, set between 1-5 to include the JS call stack. must be used in conjunction with timeline (increases overhead) (Chrome only)
* **chromeTrace**: _Boolean_, capture chrome trace (about://tracing) (Chrome only)
* **netLog**: _Boolean_, capture Network Log (Chrome only)
* **dataReduction**: _Boolean_, enable data reduction on Chrome 34+ Android (Chrome only)
* **userAgent**: _String_, custom user agent string (Chrome only)
* **commandLine**: _String_, use a list of custom command line switches (Chrome only)
* **login**: _String_, username for authenticating tests (http authentication)
* **password**: _String_, password for authenticating tests (http authentication)
* **sensitive**: _Boolean_, discard script and http headers in the result
* **disableHTTPHeaders**: _Boolean_, disable saving of the http headers (as well as browser status messages and CPU utilization)
* **block**: _String_, space-delimited list of urls to block (substring match)
* **spof**: _String_, space-delimited list of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests
* **customMetrics**: _String_, execute arbitrary JavaScript at the end of a test to collect custom metrics
* **authenticationType**: _Number_, type of authentication: 0 = Basic, 1 = SNS [0]
* **notifyEmail**: _String_, e-mail address to notify with the test results
* **pingback**: _String_, URL to ping when the test is complete (the test ID will be passed as an "id" parameter)
* **bandwidthDown**: _String_, download bandwidth in Kbps (used when specifying a custom connectivity profile)
* **bandwidthUp**: _String_, upload bandwidth in Kbps (used when specifying a custom connectivity profile)
* **browserwidth**: _String_, Browser window width (in display pixels)
* **browserheight**: _String_, Browser window height (in display pixels)
* **viewportheight**: _String_, Viewport Height in css pixels
* **viewportwidth**: _String_, Viewport Width in css pixels
* **devicetopixelratio**: _String_, Device To Pixel Ratio
* **appendua**: _String_, String to append to the user agent string. This is in addition to the default PTST/ver string
* **testtype**: _String_, For running alternative test types, can specify traceroute or lighthouse
* **profiler**: _Number_, Set to 1 to enable the V8 sampling profiler (Chromium only)
* **disableAVIF**: _Number_, Set to 1 to disable AVIF support (Chromium 88+)
* **disableWEBP**: _Number_, Set to 1 to disable WEBP support (Chromium 88+)
* **disableJXL**: _Number_, Set to 1 to disable JpegXL support (Chromium 88+)
* **dtShaper**: _Number_, Set to 1 to use Chrome's built-in traffic-shaping instead of the packet-level netem shaping usually used by the test agents
* **latency**: _String_, first-hop Round Trip Time in ms (used when specifying a custom connectivity profile)
* **packetLossRate**: _Number_, packet loss rate - percent of packets to drop (used when specifying a custom connectivity profile)
* **disableOptimization**: _Boolean_, disable optimization checks (for faster testing)
* **disableScreenshot**: _Boolean_, disable screen shot capturing
* **fullResolutionScreenshot**: _Boolean_, save a full-resolution version of the fully loaded screen shot as a PNG
* **jpegQuality**: _Number_, jpeg compression level (30-100) for the screen shots and video capture
* **medianVideo**: _Boolean_, store the video from the median run when capturing video is enabled
* **htmlBody**: _Boolean_, save the content of only the base HTML response
* **tsView**: _String_, test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
* **tsViewConfigs**: _String_, configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
* **affinity**: _String_, string to hash test to a specific test agent. tester will be picked by index among available testers
* **priority**: _Number_, change test priority (0-9) [enforced by API key, otherwise 5]
* **blockAds**: _Boolean_, block ads defined by http://adblockplus.org
* **continuousVideoCapture**: _Boolean_, capture video continuously (unstable/experimental, may cause tests to fail)
* **forceSpdy3**: _Boolean_, force SPDY version 3 (Chrome only)
* **forceSoftwareRendering**: _Boolean_, force software rendering, disable GPU acceleration (Chrome only)
* **pollResults**: _Number_, poll for results after test is scheduled at every <interval> seconds [5]
* **waitResults**: _String_, wait for test results informed by agent once complete listening on <hostname>:<port> [hostname:first port available above 8000]
* **timeout**: _String_, timeout for polling and waiting results [no timeout]
* **lighthouse**: _Boolean_, perform lighthouse test (Chrome only, Linux agent only)
- **location**: _String_, location to test from
- **connectivity**: _String_, connectivity profile -- requires location to be specified -- (Cable|DSL|3GSlow|3G|3GFast|4G|LTE|Edge|2G|Dial|FIOS|Native|custom) [Cable]
- **runs**: _Number_, number of test runs [1]
- **firstViewOnly**: _Boolean_, skip the Repeat View test
- **video**: _Boolean_, capture video
- **private**: _Boolean_, keep the test hidden from the test log
- **label**: _String_, label for the test
- **stopAtDocumentComplete**: _Boolean_, stop test at document complete. typically, tests run until all activity stops
- **disableJavaScript**: _Boolean_, disable JavaScript (IE, Chrome, Firefox)
- **clearCerts**: _Boolean_, clear SSL certificate caches
- **ignoreSSL**: _Boolean_, ignore SSL certificate errors, e.g. name mismatch, self-signed certificates, etc
- **disableCompatibilityView**: _Boolean_, forces all pages to load in standards mode (IE only)
- **tcpDump**: _Boolean_, capture network packet trace (tcpdump)
- **saveResponseBodies**: _Boolean_, save response bodies for text resources
- **keepOriginalUserAgent**: _Boolean_, do not add PTST to the original browser User Agent string
- **domElement**: _String_, DOM element to record for sub-measurement
- **minimumDuration**: _Number_, minimum test duration in seconds
- **tester**: _String_, run the test on a specific PC (name must match exactly or the test will not run)
- **emulateMobile**: _Boolean_, (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only)
- **timeline**: _Boolean_, capture Developer Tools Timeline (Chrome only)
- **timelineCallStack**: _Boolean_, set between 1-5 to include the JS call stack. must be used in conjunction with timeline (increases overhead) (Chrome only)
- **chromeTrace**: _Boolean_, capture chrome trace (about://tracing) (Chrome only)
- **netLog**: _Boolean_, capture Network Log (Chrome only)
- **dataReduction**: _Boolean_, enable data reduction on Chrome 34+ Android (Chrome only)
- **userAgent**: _String_, custom user agent string (Chrome only)
- **commandLine**: _String_, use a list of custom command line switches (Chrome only)
- **login**: _String_, username for authenticating tests (http authentication)
- **password**: _String_, password for authenticating tests (http authentication)
- **sensitive**: _Boolean_, discard script and http headers in the result
- **disableHTTPHeaders**: _Boolean_, disable saving of the http headers (as well as browser status messages and CPU utilization)
- **block**: _String_, space-delimited list of urls to block (substring match)
- **spof**: _String_, space-delimited list of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests
- **customMetrics**: _String_, execute arbitrary JavaScript at the end of a test to collect custom metrics
- **authenticationType**: _Number_, type of authentication: 0 = Basic, 1 = SNS [0]
- **notifyEmail**: _String_, e-mail address to notify with the test results
- **pingback**: _String_, URL to ping when the test is complete (the test ID will be passed as an "id" parameter)
- **bandwidthDown**: _String_, download bandwidth in Kbps (used when specifying a custom connectivity profile)
- **bandwidthUp**: _String_, upload bandwidth in Kbps (used when specifying a custom connectivity profile)
- **browserwidth**: _String_, Browser window width (in display pixels)
- **browserheight**: _String_, Browser window height (in display pixels)
- **viewportheight**: _String_, Viewport Height in css pixels
- **viewportwidth**: _String_, Viewport Width in css pixels
- **devicetopixelratio**: _String_, Device To Pixel Ratio
- **appendua**: _String_, String to append to the user agent string. This is in addition to the default PTST/ver string
- **testtype**: _String_, For running alternative test types, can specify traceroute or lighthouse
- **profiler**: _Number_, Set to 1 to enable the V8 sampling profiler (Chromium only)
- **disableAVIF**: _Number_, Set to 1 to disable AVIF support (Chromium 88+)
- **disableWEBP**: _Number_, Set to 1 to disable WEBP support (Chromium 88+)
- **disableJXL**: _Number_, Set to 1 to disable JpegXL support (Chromium 88+)
- **dtShaper**: _Number_, Set to 1 to use Chrome's built-in traffic-shaping instead of the packet-level netem shaping usually used by the test agents
- **latency**: _String_, first-hop Round Trip Time in ms (used when specifying a custom connectivity profile)
- **packetLossRate**: _Number_, packet loss rate - percent of packets to drop (used when specifying a custom connectivity profile)
- **disableOptimization**: _Boolean_, disable optimization checks (for faster testing)
- **disableScreenshot**: _Boolean_, disable screen shot capturing
- **fullResolutionScreenshot**: _Boolean_, save a full-resolution version of the fully loaded screen shot as a PNG
- **jpegQuality**: _Number_, jpeg compression level (30-100) for the screen shots and video capture
- **medianVideo**: _Boolean_, store the video from the median run when capturing video is enabled
- **htmlBody**: _Boolean_, save the content of only the base HTML response
- **tsView**: _String_, test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
- **tsViewConfigs**: _String_, configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
- **affinity**: _String_, string to hash test to a specific test agent. tester will be picked by index among available testers
- **priority**: _Number_, change test priority (0-9) [enforced by API key, otherwise 5]
- **blockAds**: _Boolean_, block ads defined by http://adblockplus.org
- **continuousVideoCapture**: _Boolean_, capture video continuously (unstable/experimental, may cause tests to fail)
- **forceSpdy3**: _Boolean_, force SPDY version 3 (Chrome only)
- **forceSoftwareRendering**: _Boolean_, force software rendering, disable GPU acceleration (Chrome only)
- **pollResults**: _Number_, poll for results after test is scheduled at every <interval> seconds [5]
- **waitResults**: _String_, wait for test results informed by agent once complete listening on <hostname>:<port> [hostname:first port available above 8000]
- **timeout**: _String_, timeout for polling and waiting results [no timeout]
- **lighthouse**: _Boolean_, perform lighthouse test (Chrome only, Linux agent only)
- **throttleCPU**: _Number_, custom cpu throttling
#### API Key (works for `runTest`, `restartTest` and `cancelTest` methods)
* **key**: _String_, API key (if assigned). Contact the WebPageTest server administrator for a key if required
- **key**: _String_, API key (if assigned). Contact the WebPageTest server administrator for a key if required
#### Request (works for `getTestStatus` `getResults` `getLocations` `getTesters` and `runTest` methods)
* **requestId**: _String_, echo request ID, useful to track asynchronous requests
- **requestId**: _String_, echo request ID, useful to track asynchronous requests
#### Results (works for `getResults` and `runTest` methods)
* **breakDown**: _Boolean_, include the breakdown of requests and bytes by mime type
* **domains**: _Boolean_, include the breakdown of requests and bytes by domain
* **pageSpeed**: _Boolean_, include the PageSpeed score in the response (may be slower)
* **requests**: _Boolean_, include the request data in the response (slower and results in much larger responses)
* **medianMetric**: _String_, set the metric used to calculate median for multiple runs tests (default: loadTime)
* **specs**: _String_, set the specs for performance test suite
* **reporter**: _String_, set performance test suite reporter output: [dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity
- **breakDown**: _Boolean_, include the breakdown of requests and bytes by mime type
- **domains**: _Boolean_, include the breakdown of requests and bytes by domain
- **pageSpeed**: _Boolean_, include the PageSpeed score in the response (may be slower)
- **requests**: _Boolean_, include the request data in the response (slower and results in much larger responses)
- **medianMetric**: _String_, set the metric used to calculate median for multiple runs tests (default: loadTime)
- **specs**: _String_, set the specs for performance test suite
- **reporter**: _String_, set performance test suite reporter output: [dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity
#### Run (works for `getPageSpeedData`, `getUtilizationData`, `getRequestData`, `getTimelineData`, `getNetLogData`, `getChromeTraceData`, `getConsoleLogData`, `getGoogleCsiData`, `getResponseBody`, `getWaterfallImage` and `getScreenshotImage` methods)
* **run**: _Number_, the test run number for multiple runs tests (default: 1, first test)
* **repeatView**: _Boolean_, if `true` returns the repeat view (cached) data
- **run**: _Number_, the test run number for multiple runs tests (default: 1, first test)
- **repeatView**: _Boolean_, if `true` returns the repeat view (cached) data
#### Image (works for `getWaterfallImage` and `getScreenshotImage` methods)
* **thumbnail**: _Boolean_, returns the thumbnail of actual image
* **dataURI**: _Boolean_, returns the base64 string representation (inline) of actual image
- **thumbnail**: _Boolean_, returns the thumbnail of actual image
- **dataURI**: _Boolean_, returns the base64 string representation (inline) of actual image
#### Screenshot (works for `getScreenshotImage` method only)
* **fullResolution**: _Boolean_, returns the full resolution screenshot in PNG format if available
* **startRender**: _Boolean_, returns the page screenshot at the Start Render point (i.e.: when something was first displayed on screen)
* **documentComplete**: _Boolean_, returns the page screenshot at the Document Complete point (i.e.: when `window.onload` was fired)
- **fullResolution**: _Boolean_, returns the full resolution screenshot in PNG format if available
- **startRender**: _Boolean_, returns the page screenshot at the Start Render point (i.e.: when something was first displayed on screen)
- **documentComplete**: _Boolean_, returns the page screenshot at the Document Complete point (i.e.: when `window.onload` was fired)
#### Waterfall (works for `getWaterfallImage` method only)
* **chartType**: _String_, set the chart type: waterfall or connection [waterfall]
* **colorByMime**: _Boolean_, set chart coloring by MIME type [false]
* **chartWidth** _Number_: chart image width in px (300-2000) [930]
* **maxTime** _Number_: set maximum time in seconds [automatic]
* **requests** _String_: filter requests (e.g.:1,2,3,4-9,8) [all]
* **noCPU**: _Boolean_, hide CPU utilization [false]
* **noBandwidth**: _Boolean_, hide bandwidth utilization [false]
* **noEllipsis**: _Boolean_, hide ellipsis (...) for missing items [false]
* **noLabels**: _Boolean_, hide labels for requests (URL) [false]
- **chartType**: _String_, set the chart type: waterfall or connection [waterfall]
- **colorByMime**: _Boolean_, set chart coloring by MIME type [false]
- **chartWidth** _Number_: chart image width in px (300-2000) [930]
- **maxTime** _Number_: set maximum time in seconds [automatic]
- **requests** _String_: filter requests (e.g.:1,2,3,4-9,8) [all]
- **noCPU**: _Boolean_, hide CPU utilization [false]
- **noBandwidth**: _Boolean_, hide bandwidth utilization [false]
- **noEllipsis**: _Boolean_, hide ellipsis (...) for missing items [false]
- **noLabels**: _Boolean_, hide labels for requests (URL) [false]
#### Video (works for `createVideo` method only)
* **comparisonEndPoint** _String_: frame comparison end point: [visual]=visually complete | all=last change | doc=document complete | full=fully loaded
- **comparisonEndPoint** _String_: frame comparison end point: [visual]=visually complete | all=last change | doc=document complete | full=fully loaded
#### Response (works for `getResponseBody` method only)
* **request** _Number_: the request number [1]
- **request** _Number_: the request number [1]
#### Listen (works for `listen` method only)
* **key** _String_: private key file path to use for SSL
* **cert** _String_: public x509 certificate file path to use for SSL
- **key** _String_: private key file path to use for SSL
- **cert** _String_: public x509 certificate file path to use for SSL
#### Location (works for `getLocations` method only)
* **allLocations** _Boolean_: if true, returns all available locations irrespective of API availability
- **allLocations** _Boolean_: if true, returns all available locations irrespective of API availability
### Examples
#### 1. Instantiating
```javascript
const WebPageTest = require('webpagetest');
const WebPageTest = require("webpagetest");
const wpt = new WebPageTest('my-wpt.foo.com'); // default: www.webpagetest.org
const wptPublic = new WebPageTest('www.webpagetest.org', 'MY_API_KEY');
const wpt = new WebPageTest("my-wpt.foo.com"); // default: www.webpagetest.org
const wptPublic = new WebPageTest("www.webpagetest.org", "MY_API_KEY");
```
#### 2. Get available locations
```javascript

@@ -632,11 +692,17 @@ wpt.getLocations((err, data) => {

#### 3. Run test on https://docs.webpagetest.org/api/integrations/ from San Jose on IE9
```javascript
wpt.runTest('https://docs.webpagetest.org/api/integrations/', {location: 'SanJose_IE9'}, (err, data) => {
console.log(err || data);
});
wpt.runTest(
"https://docs.webpagetest.org/api/integrations/",
{ location: "SanJose_IE9" },
(err, data) => {
console.log(err || data);
}
);
```
#### 4. Check current test status
```javascript
wpt.getTestStatus('121025_PT_N8K', (err, data) => {
wpt.getTestStatus("121025_PT_N8K", (err, data) => {
console.log(err || data);

@@ -647,4 +713,5 @@ });

#### 5. Get test results
```javascript
wpt.getTestResults('121025_PT_N8K', (err, data) => {
wpt.getTestResults("121025_PT_N8K", (err, data) => {
console.log(err || data);

@@ -655,36 +722,55 @@ });

#### 6. Get test waterfall thumbnail from repeat view as data URI
```javascript
wpt.getWaterfallImage('121025_PT_N8K', {
thumbnail: true,
repeatView: true,
dataURI: true
}, (err, data, info) => {
console.log(err || data, info);
});
wpt.getWaterfallImage(
"121025_PT_N8K",
{
thumbnail: true,
repeatView: true,
dataURI: true,
},
(err, data, info) => {
console.log(err || data, info);
}
);
```
#### Run test on https://docs.webpagetest.org/api/integrations/ and poll results every 5 seconds timing out in 60 seconds
```javascript
wpt.runTest('https://docs.webpagetest.org/api/integrations/', {pollResults: 5, timeout: 60}, (err, data) => {
console.log(err || data);
});
wpt.runTest(
"https://docs.webpagetest.org/api/integrations/",
{ pollResults: 5, timeout: 60 },
(err, data) => {
console.log(err || data);
}
);
```
#### Or run test on https://docs.webpagetest.org/api/integrations/ and wait results listening on localhost\* port 8000\*\*
```javascript
wpt.runTest('https://docs.webpagetest.org/api/integrations/', {waitResults: 'localhost:8000'}, (err, data) => {
console.log(err || data);
});
wpt.runTest(
"https://docs.webpagetest.org/api/integrations/",
{ waitResults: "localhost:8000" },
(err, data) => {
console.log(err || data);
}
);
```
_\* hostname and port are optional, defaults to \<system hostname\>:\<8000\>_
_\** localhost:8000 must be reacheable from WebPageTest server_
_\*\* localhost:8000 must be reacheable from WebPageTest server_
## Server mode
WebPageTest API Wrapper comes with a handy RESTful API proxy
### Command Line
```bash
$ webpagetest listen 8080 --server wpt.foo.com
```
```bash

@@ -694,2 +780,3 @@ server listening on port 8080

```
```bash

@@ -699,5 +786,7 @@ $ curl http://localhost:8080/help

```
```bash
$ webpagetest listen 8443 --key key.pem --cert cert.pem --server wpt.foo.com
```
```bash

@@ -709,11 +798,13 @@ server listening on port 8443

#### Notes
* port _8080_ is optional, default port is _7791_
* `wpt.foo.com` is overriding the default `www.webpagetest.org` server but can still be overridden with `server` option
* when _--key_ and _--cert_ are provided, HTTPS is used instead of default HTTP server
- port _8080_ is optional, default port is _7791_
- `wpt.foo.com` is overriding the default `www.webpagetest.org` server but can still be overridden with `server` option
- when _--key_ and _--cert_ are provided, HTTPS is used instead of default HTTP server
### Module
```javascript
const server = wpt.listen(8080, (err, data) => {
if (err) throw err;
console.log('listening on ' + data.url);
console.log("listening on " + data.url);
}); // listen on port 8080 (optional), default port is 7791

@@ -723,3 +814,3 @@

server.close(() => {
console.log('server closed');
console.log("server closed");
});

@@ -730,9 +821,13 @@ }, 10000); // wait for 10s before stop listening

## Batch
Batch command is available as command line only and loads a batch file containing one WebPageTest CLI command with options per line. It runs all commands in parallel, but returns an array of results in order as they appear in the batch file once all results are ready. The exit status code is the sum of all individual commands' exit status code.
By running
```bash
$ webpagetest batch commands.txt
```
where `commands.txt` contains:
```

@@ -742,3 +837,5 @@ test https://docs.webpagetest.org/api/integrations/ --first --location foo

```
It schedules the 2 tests above returning an array of size 2 in the same order as in `commands.txt` file:
```javascript

@@ -762,11 +859,14 @@ [

```
With exit status 0 in case none of commands returns an error:
```bash
$ echo $?
0
````
```
By running multiple sync tests, i.e. with either `--poll` or `--wait`, all tests are scheduled and results are polled or wait in parallel; meaning, if tests are set to run in different locations or same location with multiple agents, the final result might come together, but the result array will only return once *all* tests are done. e.g.:
By running multiple sync tests, i.e. with either `--poll` or `--wait`, all tests are scheduled and results are polled or wait in parallel; meaning, if tests are set to run in different locations or same location with multiple agents, the final result might come together, but the result array will only return once _all_ tests are done. e.g.:
`commands.txt`:
```

@@ -784,2 +884,3 @@ test https://docs.webpagetest.org/api/integrations/ --first --location foo --poll --timeout 60

## Tests
```bash

@@ -799,3 +900,3 @@ $ npm test

+ https://github.com/WebPageTest
- https://github.com/WebPageTest

@@ -811,2 +912,3 @@ ## License

---
<p align="center"><a href="https://docs.webpagetest.org/api/integrations/#officially-supported-integrations">Learn about more WebPageTest API Integrations in our docs</a></p>

@@ -21,4 +21,5 @@ Usage: webpagetest results [options] <id>

[dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity
--proxy set the proxy used to fetch results
-e, --request <id> echo request ID, useful to track asynchronous
requests
-h, --help display help for command

@@ -63,2 +63,3 @@ Usage: webpagetest test [options] <url_or_script>

Linux agent only)
-thc, --throttleCPU <number> custom cpu throttling
-g, --login <username> username for authenticating tests (http

@@ -91,3 +92,3 @@ authentication)

-U, --bwup <bandwidth> upload bandwidth in Kbps (used when
specifying a custom connectivity profile)
specifying a custom connectivity profile)
-bw, --browserwidth <pixels> Browser window width (in display pixels)

@@ -177,2 +178,3 @@ -bh, --browserheight <pixels> Browser window height (in display pixels)

[dot]|spec|tap|xunit|list|progress|min|nyan|landing|json|doc|markdown|teamcity
--proxy set the proxy used to fetch results
-h, --help display help for command
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc