Skip to content

Commit aa1cc94

Browse files
committed
Replaced xmlResult.php by jsonResult.php WPT API endpoint for fetching test results
1 parent c694733 commit aa1cc94

30 files changed

Lines changed: 22234 additions & 4170 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ $ npm test
670670

671671
## Changelog
672672

673+
* 0.3.0: Replaced xmlResult.php by jsonResult.php WPT API endpoint for fetching test results
673674
* 0.2.5: Added test options: custom, chrometrace, callstack, tester; Added chrometrace command (`getChromeTraceData` method)
674675
* 0.2.4: Added test options: clearcerts, medianvideo, datareduction, useragent and tsview; HTTPS support to listen/proxy server
675676
* 0.2.3: Updated DevTools Timeline API url endpoint for timeline command

lib/specs.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ function specsRunner(specs, reporter, callback, err, data) {
108108
path = [];
109109

110110
// bail if test not complete
111-
if (!err && (!data || data && data.response &&
112-
data.response.statusCode !== 200)) {
111+
if (!err && (!data || data.statusCode !== 200)) {
113112
return callback(err, data);
114113
}
115114

@@ -141,15 +140,15 @@ function specsRunner(specs, reporter, callback, err, data) {
141140
// error handling
142141
if (specs instanceof Error) {
143142
err = err || specs;
144-
} else if (!(data && data.response && data.response.data)) {
143+
} else if (!(data && data.data)) {
145144
err = err || new Error('no data');
146145
}
147146

148147
if (err) {
149148
tests.push({text: err.message, result: err});
150149
} else {
151150
defaults = specs.defaults || {};
152-
traverse(specs, data.response.data);
151+
traverse(specs, data.data);
153152
}
154153

155154
// run mocha suite

lib/webpagetest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var reSpace = /\s/,
2121

2222
var paths = {
2323
testStatus: 'testStatus.php',
24-
testResults: 'xmlResult.php',
24+
testResults: 'jsonResult.php',
2525
locations: 'getLocations.php',
2626
testers: 'getTesters.php',
2727
test: 'runtest.php',
@@ -404,7 +404,7 @@ function runTest(what, options, callback) {
404404

405405
// poll results
406406
if (options.pollResults && !options.dryRun) {
407-
options.pollResults = (parseInt(options.pollResults, 10) || 5) * 1000;
407+
options.pollResults = parseInt(options.pollResults * 1000, 10) || 5000;
408408

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpagetest",
3-
"version": "0.2.5",
3+
"version": "0.3.0",
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",
@@ -34,12 +34,12 @@
3434
},
3535
"dependencies": {
3636
"commander": "~2.3.0",
37-
"csv": "~0.4.0",
37+
"csv": "~0.4.1",
3838
"entities": "~1.1.1",
3939
"mocha": "~1.21.4",
4040
"xml2js": "~0.4.4"
4141
},
4242
"devDependencies": {
43-
"nock": "~0.48.0"
43+
"nock": "~0.48.2"
4444
}
4545
}

test/command-line-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('WebPageTest Command Line', function() {
4141
exec(mock('results 120816_V2_2'), function(err, data) {
4242
if (err) return done(err);
4343
data = JSON.parse(data);
44-
assert.equal(data.url, wptServer + 'xmlResult.php?test=120816_V2_2');
44+
assert.equal(data.url, wptServer + 'jsonResult.php?test=120816_V2_2');
4545
done();
4646
});
4747
});
@@ -51,17 +51,17 @@ describe('WebPageTest Command Line', function() {
5151
if (err) return done(err);
5252
data = JSON.parse(data);
5353
assert.equal(data.url, wptServer +
54-
'xmlResult.php?test=120816_V2_2&medianMetric=TTFB');
54+
'jsonResult.php?test=120816_V2_2&medianMetric=TTFB');
5555
done();
5656
});
5757
});
5858

5959
it('gets a test results with extra data input returns the API url', function(done) {
60-
exec(mock('results 130724_YD_8JX -bDpR'), function(err, data) {
60+
exec(mock('results 141106_8N_ZRC -bDpR'), function(err, data) {
6161
if (err) return done(err);
6262
data = JSON.parse(data);
6363
assert.equal(data.url, wptServer +
64-
'xmlResult.php?test=130724_YD_8JX&breakdown=1&domains=1&pagespeed=1&requests=1');
64+
'jsonResult.php?test=141106_8N_ZRC&breakdown=1&domains=1&pagespeed=1&requests=1');
6565
done();
6666
});
6767
});
@@ -328,7 +328,7 @@ describe('WebPageTest Command Line', function() {
328328
if (err) return done(err);
329329
data = JSON.parse(data);
330330
assert.equal(data[0].url, wptServer + 'testStatus.php?test=120816_V2_2');
331-
assert.equal(data[1].url, wptServer + 'xmlResult.php?test=120816_V2_2');
331+
assert.equal(data[1].url, wptServer + 'jsonResult.php?test=120816_V2_2');
332332
done();
333333
});
334334
});

test/dryrun-test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Dry Run', function() {
3636
it('gets a test results request', function(done) {
3737
wpt.getTestResults('120816_V2_2', {dryRun: true}, function (err, data) {
3838
if (err) return done(err);
39-
assert.equal(data.url, wptServer + 'xmlResult.php?test=120816_V2_2');
39+
assert.equal(data.url, wptServer + 'jsonResult.php?test=120816_V2_2');
4040
done();
4141
});
4242
});
@@ -47,7 +47,7 @@ describe('Dry Run', function() {
4747
dryRun: true
4848
}, function (err, data) {
4949
if (err) return done(err);
50-
assert.equal(data.url, wptServer + 'xmlResult.php?test=120816_V2_2&r=12345');
50+
assert.equal(data.url, wptServer + 'jsonResult.php?test=120816_V2_2&r=12345');
5151
done();
5252
});
5353
});
@@ -59,13 +59,13 @@ describe('Dry Run', function() {
5959
}, function (err, data) {
6060
if (err) return done(err);
6161
assert.equal(data.url, wptServer +
62-
'xmlResult.php?test=120816_V2_2&medianMetric=TTFB');
62+
'jsonResult.php?test=120816_V2_2&medianMetric=TTFB');
6363
done();
6464
});
6565
});
6666

6767
it('gets a test results with extra data request', function(done) {
68-
wpt.getTestResults('130724_YD_8JX', {
68+
wpt.getTestResults('141106_8N_ZRC', {
6969
breakDown: true,
7070
domains: true,
7171
pageSpeed: true,
@@ -74,7 +74,7 @@ describe('Dry Run', function() {
7474
}, function (err, data) {
7575
if (err) return done(err);
7676
assert.equal(data.url, wptServer +
77-
'xmlResult.php?test=130724_YD_8JX&breakdown=1&domains=1&pagespeed=1&requests=1');
77+
'jsonResult.php?test=141106_8N_ZRC&breakdown=1&domains=1&pagespeed=1&requests=1');
7878
done();
7979
});
8080
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-L, --label <label> label for the test
1515
-i, --onload stop test at document complete. typically, tests run until all activity stops
1616
-S, --noscript disable javascript (IE, Chrome, Firefox)
17-
-C, --clearcerts clear SSL cetificate caches
17+
-C, --clearcerts clear SSL certificate caches
1818
-R, --ignoressl ignore SSL certificate errors, e.g. name mismatch, self-signed certificates, etc
1919
-T, --standards forces all pages to load in standards mode (IE only)
2020
-u, --tcpdump capture network packet trace (tcpdump)

test/fixtures/command-line/help.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
cancel running/pending test
2323

2424
har <id>
25-
get the HTTPS Archive (HAR) from test
25+
get the HTTP Archive (HAR) from test
2626

2727
pagespeed [options] <id>
2828
get the Google Page Speed results (if available) from test

0 commit comments

Comments
 (0)