Skip to content

Commit 161e1fa

Browse files
committed
fix(errors): update webdriverjs, fix asynchronous error output
Add some console logging, remove useless info about the last running task in the control flow, and fix error where problems reported from done.fail were getting pushed into the following spec. Closes #18
1 parent fdb03a3 commit 161e1fa

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

index.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ function wrapInControlFlow(globalFn, fnName) {
7575
function asyncTestFn(fn) {
7676
return function(done) {
7777
// deferred object for signaling completion of asychronous function within globalFn
78-
var asyncFnDone = webdriver.promise.defer(),
79-
originalFail = jasmine.getEnv().fail;
78+
var asyncFnDone = webdriver.promise.defer();
8079

8180
if (fn.length === 0) {
8281
// function with globalFn not asychronous
@@ -86,20 +85,19 @@ function wrapInControlFlow(globalFn, fnName) {
8685
} else {
8786
// Add fail method to async done callback and override env fail to
8887
// reject async done promise
89-
jasmine.getEnv().fail = asyncFnDone.fulfill.fail = function(userError) {
88+
asyncFnDone.fulfill.fail = function(userError) {
9089
asyncFnDone.reject(new Error(userError));
9190
};
91+
9292
}
9393

9494
var flowFinished = flow.execute(function() {
9595
fn.call(jasmine.getEnv(), asyncFnDone.fulfill);
96-
});
96+
}, 'Run ' + fnName + ' in control flow');
9797

9898
webdriver.promise.all([asyncFnDone, flowFinished]).then(function() {
99-
jasmine.getEnv().fail = originalFail;
10099
seal(done)();
101100
}, function(e) {
102-
jasmine.getEnv().fail = originalFail;
103101
e.stack = e.stack + '\n==== async task ====\n' + driverError.stack;
104102
done.fail(e);
105103
});
@@ -171,7 +169,7 @@ jasmine.Expectation.prototype.wrapCompare = function(name, matcherFactory) {
171169
return compare(actual, expected);
172170
});
173171
});
174-
});
172+
}, 'Expect ' + name);
175173

176174
function compare(actual, expected) {
177175
var args = expected.slice(0);
@@ -258,10 +256,5 @@ OnTimeoutReporter.prototype.specDone = function(result) {
258256
// get to complete first.
259257
jasmine.getEnv().addReporter(new OnTimeoutReporter(function() {
260258
console.warn('A Jasmine spec timed out. Resetting the WebDriver Control Flow.');
261-
console.warn('The last active task was: ');
262-
console.warn(
263-
(flow.activeFrame_ && flow.activeFrame_.getPendingTask() ?
264-
flow.activeFrame_.getPendingTask().toString() :
265-
'unknown'));
266259
flow.reset();
267260
}));

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"devDependencies": {
1515
"jshint": "2.5.0",
1616
"jasmine": "2.1.1",
17-
"selenium-webdriver": "2.43.4"
17+
"selenium-webdriver": "2.45.1"
1818
},
1919
"repository": {
2020
"type": "git",

spec/common.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ exports.getFakeDriver = function() {
1313
setUp: function() {
1414
return flow.execute(function() {
1515
return webdriver.promise.fulfilled('setup done');
16-
});
16+
}, 'setUp');
1717
},
1818
getValueA: function() {
1919
return flow.execute(function() {
2020
return webdriver.promise.delayed(500).then(function() {
2121
return webdriver.promise.fulfilled('a');
2222
});
23-
});
23+
}, 'getValueA');
2424
},
2525
getOtherValueA: function() {
2626
return flow.execute(function() {
2727
return webdriver.promise.fulfilled('a');
28-
});
28+
}, 'getOtherValueA');
2929
},
3030
getValueB: function() {
3131
return flow.execute(function() {
3232
return webdriver.promise.fulfilled('b');
33-
});
33+
}, 'getValueB');
3434
},
3535
getBigNumber: function() {
3636
return flow.execute(function() {
3737
return webdriver.promise.fulfilled(1111);
38-
});
38+
}, 'getBigNumber');
3939
},
4040
getSmallNumber: function() {
4141
return flow.execute(function() {
4242
return webdriver.promise.fulfilled(11);
43-
});
43+
}, 'getSmallNumber');
4444
},
4545
getDecimalNumber: function() {
4646
return flow.execute(function() {
4747
return webdriver.promise.fulfilled(3.14159);
48-
});
48+
}, 'getDecimalNumber');
4949
},
5050
getDisplayedElement: function() {
5151
return flow.execute(function() {
@@ -54,7 +54,7 @@ exports.getFakeDriver = function() {
5454
return webdriver.promise.fulfilled(true);
5555
}
5656
});
57-
});
57+
}, 'getDisplayedElement');
5858
},
5959
getHiddenElement: function() {
6060
return flow.execute(function() {
@@ -63,7 +63,7 @@ exports.getFakeDriver = function() {
6363
return webdriver.promise.fulfilled(false);
6464
}
6565
});
66-
});
66+
}, 'getHiddenElement');
6767
}
6868
};
6969
};

spec/errorSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('things that should fail', function() {
3131
});
3232

3333
it('should pass errors from done callback', function(done) {
34-
done.fail('an error');
34+
done.fail('an error from done.fail');
3535
});
3636

3737
it('should fail normal synchronous tests', function() {

0 commit comments

Comments
 (0)