Skip to content

Commit bcab7ba

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents e0739ad + b4eb56b commit bcab7ba

31 files changed

Lines changed: 140 additions & 119 deletions

README.md

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
## WebPageTest API Wrapper for NodeJS
22

3-
[![NPM](https://nodei.co/npm/webpagetest.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/webpagetest/)
4-
[![Build Status](https://secure.travis-ci.org/marcelduran/webpagetest-api.png?branch=master)](http://travis-ci.org/marcelduran/webpagetest-api)
3+
[![Build Status](https://secure.travis-ci.org/marcelduran/webpagetest-api.png?branch=master)](https://travis-ci.org/marcelduran/webpagetest-api)
4+
[![NPM Version](https://img.shields.io/npm/v/webpagetest.svg?style=flat)](https://www.npmjs.org/package/webpagetest)
5+
[![NPM Downloads](https://img.shields.io/npm/dm/webpagetest.svg?style=flat)](https://www.npmjs.org/package/webpagetest)
56
[![Dependencies Status](https://david-dm.org/marcelduran/webpagetest-api.png)](https://david-dm.org/marcelduran/webpagetest-api)
67

7-
[WebPageTest API Wrapper](http://marcelduran.com/webpagetest-api) is a [NPM](http://npmjs.org) package that wraps [WebPageTest](https://github.com/WPO-Foundation/webpagetest) API for [NodeJS](http://nodejs.org) as a module and a command-line tool.
8+
[WebPageTest API Wrapper](https://marcelduran.com/webpagetest-api) is a [NPM](https://npmjs.org) package that wraps [WebPageTest](https://github.com/WPO-Foundation/webpagetest) API for [NodeJS](https://nodejs.org) as a module and a command-line tool.
89

910
## Getting started
1011

@@ -16,15 +17,15 @@ $ npm install webpagetest -g
1617

1718
### Command line
1819
```bash
19-
$ webpagetest test http://twitter.com/marcelduran
20+
$ webpagetest test https://twitter.com/marcelduran
2021
```
2122

2223
### Module
2324
```javascript
2425
var WebPageTest = require('webpagetest');
2526
var wpt = new WebPageTest('www.webpagetest.org');
2627

27-
wpt.runTest('http://twitter.com/marcelduran', function(err, data) {
28+
wpt.runTest('https://twitter.com/marcelduran', function(err, data) {
2829
console.log(err || data);
2930
});
3031
```
@@ -123,7 +124,9 @@ _The default WPT server can also be specified via environment variable `WEBPAGET
123124
* **-A, --medianvideo**: store the video from the median run when capturing video is enabled
124125
* **--htmlbody**: save the content of only the base HTML response
125126
* **--tsview** _\<id\>_: test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
127+
* **--tsviewconfigs** _\<string\>_: configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
126128
* **--affinity** _\<string\>_: string to hash test to a specific test agent. tester will be picked by index among available testers
129+
* **--priority** _\<number\>_: change test priority (0-9) [enforced by API key, otherwise 5]
127130
* **--noads**: block ads defined by adblockrules.org
128131
* **--continuous**: capture video continuously (unstable/experimental, may cause tests to fail)
129132
* **--spdy3**: force SPDY version 3 (Chrome only)
@@ -133,7 +136,7 @@ _The default WPT server can also be specified via environment variable `WEBPAGET
133136
* **--timeout** _\<seconds\>_: timeout for polling and waiting results [no timeout]
134137

135138
#### API Key (works for **test** and **cancel** commands)
136-
* **-k, --key** _\<api_key\>_:API key (if assigned). Contact the WebPageTest server administrator for a key if required
139+
* **-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)
137140

138141
#### Request (works for **status**, **results**, **locations**, **testers** and **test** commands)
139142
* **-e, --request** _\<id\>_: echo request ID, useful to track asynchronous requests
@@ -212,9 +215,9 @@ $ webpagetest locations
212215
}
213216
```
214217

215-
#### 2. Run test on http://twitter.com/marcelduran from San Jose on IE9
218+
#### 2. Run test on https://twitter.com/marcelduran from San Jose on IE9
216219
```bash
217-
$ webpagetest test http://twitter.com/marcelduran --key 1F2A3K4E5 --location SanJose_IE9
220+
$ webpagetest test https://twitter.com/marcelduran --key 1F2A3K4E5 --location SanJose_IE9
218221
```
219222
```javascript
220223
{
@@ -223,11 +226,11 @@ $ webpagetest test http://twitter.com/marcelduran --key 1F2A3K4E5 --location San
223226
"data": {
224227
"testId": "121025_PT_N8K",
225228
"ownerKey": "868cb2813a0f376a977dd1a24ab041b4f12361b3",
226-
"jsonUrl": "http://localhost/results.php?test=121025_PT_N8K&f=json",
227-
"xmlUrl": "http://localhost/xmlResult.php?test=121025_PT_N8K",
228-
"userUrl": "http://localhost/results.php?test=121025_PT_N8K",
229-
"summaryCSV": "http://localhost/csv.php?test=121025_PT_N8K",
230-
"detailCSV": "http://localhost/csv.php?test=121025_PT_N8K&amp;requests=1"
229+
"jsonUrl": "https://www.webpagetest.org/results.php?test=121025_PT_N8K&f=json",
230+
"xmlUrl": "https://www.webpagetest.org/xmlResult.php?test=121025_PT_N8K",
231+
"userUrl": "https://www.webpagetest.org/results.php?test=121025_PT_N8K",
232+
"summaryCSV": "https://www.webpagetest.org/csv.php?test=121025_PT_N8K",
233+
"detailCSV": "https://www.webpagetest.org/csv.php?test=121025_PT_N8K&amp;requests=1"
231234
}
232235
}
233236
```
@@ -261,8 +264,8 @@ $ webpagetest results 121025_PT_N8K
261264
"statusCode": 200, "statusText": "Ok",
262265
"data": {
263266
"testId": "121025_PT_N8K",
264-
"summary": "http://www.webpagetest.org/result/121025_PT_N8K/",
265-
"testUrl": "http://twitter.com/marcelduran",
267+
"summary": "https://www.webpagetest.org/result/121025_PT_N8K/",
268+
"testUrl": "https://twitter.com/marcelduran",
266269
"location": "SanJose_IE9",
267270
"connectivity": "DSL",
268271
"bwDown": 1500, "bwUp": 384, "latency": 50, "plr": 0,
@@ -295,21 +298,21 @@ $ webpagetest waterfall 121025_PT_N8K --thumbnail --cached --uri
295298
}
296299
```
297300

298-
#### Run test on http://twitter.com/marcelduran and poll results every 5 seconds timing out in 60 seconds
301+
#### Run test on https://twitter.com/marcelduran and poll results every 5 seconds timing out in 60 seconds
299302
```bash
300-
$ webpagetest test http://twitter.com/marcelduran --poll 5 --timeout 60
303+
$ webpagetest test https://twitter.com/marcelduran --poll 5 --timeout 60
301304
```
302-
#### Or run test on http://twitter.com/marcelduran and wait for results listening on localhost\* port 8000\**
305+
#### Or run test on https://twitter.com/marcelduran and wait for results listening on localhost\* port 8000\**
303306
```bash
304-
$ webpagetest test http://twitter.com/marcelduran --wait 8000
307+
$ webpagetest test https://twitter.com/marcelduran --wait 8000
305308
```
306309
```javascript
307310
{
308311
"response": {
309312
"statusCode": 200, "statusText": "Ok",
310313
"data": {
311314
"testId": "121025_PT_N8K",
312-
"testUrl": "http://twitter.com/marcelduran",
315+
"testUrl": "https://twitter.com/marcelduran",
313316
...
314317
"median": {
315318
"firstView": {
@@ -446,7 +449,9 @@ wpt.runTest(script, function(err, data) {
446449
* **medianVideo**: _Boolean_, store the video from the median run when capturing video is enabled
447450
* **htmlBody**: _Boolean_, save the content of only the base HTML response
448451
* **tsView**: _String_, test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
452+
* **tsViewConfigs**: _String_, configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)
449453
* **affinity**: _String_, string to hash test to a specific test agent. tester will be picked by index among available testers
454+
* **priority**: _Number_, change test priority (0-9) [enforced by API key, otherwise 5]
450455
* **blockAds**: _Boolean_, block ads defined by adblockrules.org
451456
* **continuousVideoCapture**: _Boolean_, capture video continuously (unstable/experimental, may cause tests to fail)
452457
* **forceSpdy3**: _Boolean_, force SPDY version 3 (Chrome only)
@@ -521,9 +526,9 @@ wpt.getLocations(function(err, data) {
521526
});
522527
```
523528

524-
#### 3. Run test on http://twitter.com/marcelduran from San Jose on IE9
529+
#### 3. Run test on https://twitter.com/marcelduran from San Jose on IE9
525530
```javascript
526-
wpt.runTest('http://twitter.com/marcelduran', {location: 'SanJose_IE9'}, function(err, data) {
531+
wpt.runTest('https://twitter.com/marcelduran', {location: 'SanJose_IE9'}, function(err, data) {
527532
console.log(err || data);
528533
});
529534
```
@@ -553,16 +558,16 @@ wpt.getWaterfallImage('121025_PT_N8K', {
553558
});
554559
```
555560

556-
#### Run test on http://twitter.com/marcelduran and poll results every 5 seconds timing out in 60 seconds
561+
#### Run test on https://twitter.com/marcelduran and poll results every 5 seconds timing out in 60 seconds
557562
```javascript
558-
wpt.runTest('http://twitter.com/marcelduran', {pollResults: 5, timeout: 60}, function(err, data) {
563+
wpt.runTest('https://twitter.com/marcelduran', {pollResults: 5, timeout: 60}, function(err, data) {
559564
console.log(err || data);
560565
});
561566
```
562567

563-
#### Or run test on http://twitter.com/marcelduran and wait results listening on localhost\* port 8000\*\*
568+
#### Or run test on https://twitter.com/marcelduran and wait results listening on localhost\* port 8000\*\*
564569
```javascript
565-
wpt.runTest('http://twitter.com/marcelduran', {waitResults: 'localhost:8000'}, function(err, data) {
570+
wpt.runTest('https://twitter.com/marcelduran', {waitResults: 'localhost:8000'}, function(err, data) {
566571
console.log(err || data);
567572
});
568573
```
@@ -670,13 +675,14 @@ $ npm test
670675

671676
## Changelog
672677

678+
* 0.3.2: Updated deps and fixed test runs with specs
673679
* 0.3.1: Added dummy url when scripting, needed for webdriver scripting on mobbile agents
674680
* 0.3.0: Replaced xmlResult.php by jsonResult.php WPT API endpoint for fetching test results
675681
* 0.2.5: Added test options: custom, chrometrace, callstack, tester; Added chrometrace command (`getChromeTraceData` method)
676682
* 0.2.4: Added test options: clearcerts, medianvideo, datareduction, useragent and tsview; HTTPS support to listen/proxy server
677683
* 0.2.3: Updated DevTools Timeline API url endpoint for timeline command
678684
* 0.2.2: Added response body command/method
679-
* 0.2.1: Added history, video, player, googleCsi commands and continuous option
685+
* 0.2.1: Added history, video, player, googleCsi commands and continuous option
680686
* 0.2.0: Replaced jsonml by xml2js dependency
681687
* 0.1.3: Test results extra data (breakdown, domains, requests, pagespeed)
682688
* 0.1.0: Specs (CI); Run in batch; Node methods/options as command aliases; new Chrome test options
@@ -695,16 +701,15 @@ https://github.com/marcelduran/webpagetest-api/issues
695701

696702
**Marcel Duran**
697703

698-
+ http://github.com/marcelduran
704+
+ https://github.com/marcelduran
699705

700706
## License
701707

702-
Copyright 2013 Twitter Inc.
703-
Copyright 2014 Google Inc.
704-
Copyright 2014 Marcel Duran and other contributors
708+
Copyright 2013 Twitter Inc.
709+
Copyright 2015 Google Inc.
710+
Copyright 2015 Marcel Duran and other contributors
705711

706-
Licensed under the [MIT License](http://github.com/marcelduran/webpagetest-api/raw/master/LICENSE)
712+
Licensed under the [MIT License](https://github.com/marcelduran/webpagetest-api/raw/master/LICENSE)
707713

708714

709715
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/marcelduran/webpagetest-api/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
710-

lib/mapping.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,25 @@ var options = {
371371
param: 'id',
372372
info: 'test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)'
373373
},
374+
'tsviewconfigs': {
375+
name: 'tsViewConfigs',
376+
api: 'tsview_configs',
377+
param: 'string',
378+
info: 'configs to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)'
379+
},
374380
'affinity': {
375381
name: 'affinity',
376382
api: 'affinity',
377383
param: 'string',
378384
info: 'string to hash test to a specific test agent. tester will be picked by index among available testers'
379385
},
380-
386+
'priority': {
387+
name: 'priority',
388+
api: 'priority',
389+
param: 'number',
390+
info: 'change test priority (0-9) [enforced by API key, otherwise 5]',
391+
valid: /^\d$/
392+
},
381393
// Undocumented/experimental/transitent/deprecated
382394
'noads': {
383395
name: 'blockAds',

lib/specs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ function specsRunner(specs, reporter, callback, err, data) {
156156

157157
// run mocha suite
158158
var mocha = new Mocha({reporter: reporter});
159-
mocha.suite.emit('pre-require', global);
159+
mocha.suite.emit('pre-require', global, null, mocha);
160160
buildSuite(defaults, tests);
161161
mocha.run(callback || function(failures) {
162162
process.exit(failures);

lib/webpagetest.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function get(config, pathname, proxy, callback, encoding) {
6565
headers: {
6666
Host: config.hostname
6767
}
68-
} :
68+
} :
6969
{
7070
path: pathname,
7171
host: config.hostname,
@@ -132,7 +132,7 @@ function get(config, pathname, proxy, callback, encoding) {
132132
});
133133
}
134134

135-
// execute callback properly normalizing optional args
135+
// execute callback properly normalizing optional args
136136
function callbackYield(callback, err, data, options) {
137137
if (typeof callback === 'function') {
138138
callback.apply(callback, [err, data].concat(options.args));
@@ -335,8 +335,8 @@ function runTest(what, options, callback) {
335335
function poll(err, data) {
336336
// poll again when test started but not complete
337337
// and not when specs are done testing
338-
if (!err && (!data || data && data.response &&
339-
data.response.statusCode !== 200) &&
338+
if (!err && (!data || data && data.data &&
339+
data.statusCode !== 200) &&
340340
!(typeof err === 'number' && data === undefined)) {
341341
polling = setTimeout(getTestResults.bind(this, testId,
342342
resultsOptions, poll.bind(this)), options.pollResults);

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpagetest",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "WebPageTest API wrapper for NodeJS",
55
"author": "Marcel Duran <github@marcelduran.com> (http://github.com/marcelduran)",
66
"homepage": "http://github.com/marcelduran/webpagetest-api",
@@ -33,13 +33,13 @@
3333
"node": ">=0.10.1"
3434
},
3535
"dependencies": {
36-
"commander": "~2.3.0",
37-
"csv": "~0.4.1",
38-
"entities": "~1.1.1",
39-
"mocha": "~1.21.4",
40-
"xml2js": "~0.4.4"
36+
"commander": "^2.7.1",
37+
"csv": "^0.4.1",
38+
"entities": "^1.1.1",
39+
"mocha": "^2.2.4",
40+
"xml2js": "^0.4.6"
4141
},
4242
"devDependencies": {
43-
"nock": "~0.48.2"
43+
"nock": "~1.5.0"
4444
}
4545
}

test/fixtures/command-line/help-batch.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Usage: batch [options] <file>
33

4+
run commands in batch, i.e. one command per line from <file> in parallel
5+
46
Options:
57

68
-h, --help output usage information

test/fixtures/command-line/help-cancel.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Usage: cancel [options] <id>
33

4+
cancel running/pending test
5+
46
Options:
57

68
-h, --help output usage information

test/fixtures/command-line/help-chrometrace.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Usage: chrometrace [options] <id>
33

4+
get the Chrome Trace data (if available) from test
5+
46
Options:
57

68
-h, --help output usage information

test/fixtures/command-line/help-console.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Usage: console [options] <id>
33

4+
get the browser console log data (if available) from test
5+
46
Options:
57

68
-h, --help output usage information

test/fixtures/command-line/help-googlecsi.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Usage: googlecsi [options] <id>
33

4+
get Google CSI data (Client Side Instrumentation)
5+
46
Options:
57

68
-h, --help output usage information

0 commit comments

Comments
 (0)