Skip to content

Commit 4ab1375

Browse files
committed
fixed sync test with poll and specs
1 parent 009cded commit 4ab1375

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/specs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ function specsRunner(specs, reporter, callback, err, data) {
100100
tests = [],
101101
path = [];
102102

103+
// bail if test not complete
104+
if (!err && (!data || data && data.response &&
105+
data.response.statusCode !== 200)) {
106+
return callback(err, data);
107+
}
108+
103109
function traverse(specs, data) {
104110
Object.keys(specs).forEach(function(key) {
105111
// bail on default

lib/webpagetest.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,11 @@ function runTest(what, options, callback) {
280280
}
281281

282282
function poll(err, data) {
283+
// poll again when test started but not complete
284+
// and not when specs are done testing
283285
if (!err && (!data || data && data.response &&
284-
data.response.statusCode !== 200)) {
286+
data.response.statusCode !== 200) &&
287+
!(typeof err === 'number' && data === undefined)) {
285288
polling = setTimeout(getTestResults.bind(this, testId,
286289
resultsOptions, poll.bind(this)), options.pollResults);
287290
} else {

0 commit comments

Comments
 (0)