Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 6d85ab4

Browse files
DavidMikeSimonjuliemr
authored andcommitted
fix(jasminewd): display stack traces in correct order and with WebElement method failure details
1 parent 8964ac9 commit 6d85ab4

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

Diff for: jasminewd/index.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,23 @@ function seal(fn) {
2525
* @param {!Function} globalFn The function to wrap.
2626
* @return {!Function} The new function.
2727
*/
28-
function wrapInControlFlow(globalFn) {
28+
function wrapInControlFlow(globalFn, fnName) {
2929
return function() {
3030
var driverError = new Error();
3131
driverError.stack = driverError.stack.replace(/ +at.+jasminewd.+\n/, '');
3232

33+
var description = 'Asynchronous test function: ' + fnName + '(';
34+
if (arguments.length >= 2) {
35+
description += '"' + arguments[0] + '"';
36+
}
37+
description += ')';
38+
3339
function asyncTestFn(fn) {
3440
return function(done) {
3541
var thing = flow.execute(function() {
3642
fn.call(jasmine.getEnv().currentSpec);
37-
}, 'asynchronous test function').then(seal(done), function(e) {
38-
e.stack = driverError.stack + '\nAt async task:\n ' + e.stack;
43+
}, description).then(seal(done), function(e) {
44+
e.stack = e.stack + '==== async task ====\n' + driverError.stack;
3945
done(e);
4046
});
4147
};
@@ -62,10 +68,10 @@ function wrapInControlFlow(globalFn) {
6268
};
6369
};
6470

65-
global.it = wrapInControlFlow(global.it);
66-
global.iit = wrapInControlFlow(global.iit);
67-
global.beforeEach = wrapInControlFlow(global.beforeEach);
68-
global.afterEach = wrapInControlFlow(global.afterEach);
71+
global.it = wrapInControlFlow(global.it, 'it');
72+
global.iit = wrapInControlFlow(global.iit, 'iit');
73+
global.beforeEach = wrapInControlFlow(global.beforeEach, 'beforeEach');
74+
global.afterEach = wrapInControlFlow(global.afterEach, 'afterEach');
6975

7076

7177
/**

Diff for: lib/protractor.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,14 @@ var buildElementHelper = function(ptor, opt_usingChain) {
109109
['findElements', 'isElementPresent', 'evaluate', '$$']);
110110
webElementFns.forEach(function(fnName) {
111111
elementFinder[fnName] = function() {
112+
var callerError = new Error();
112113
var args = arguments;
113114

114115
return using().findElement(locator).then(function(element) {
115-
return element[fnName].apply(element, args);
116-
}, function(error) {
117-
throw error;
116+
return element[fnName].apply(element, args).then(null, function(e) {
117+
e.stack = e.stack + '\n' + callerError.stack;
118+
throw e;
119+
});
118120
});
119121
};
120122
});

0 commit comments

Comments
 (0)