-
Notifications
You must be signed in to change notification settings - Fork 36
chore(promises): Wait for promises explicitly #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
d45aa6e
to
4ab4f2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great overall 👍
} | ||
}, flow); | ||
}, 'Run ' + fnName + description + ' in control flow').then(seal(done), function(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The seal
function isn't used any more, so its declaration can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -78,30 +94,38 @@ function wrapInControlFlow(flow, globalFn, fnName) { | |||
|
|||
flow.execute(function controlFlowExecute() { | |||
return new webdriver.promise.Promise(function(fulfill, reject) { | |||
function wrappedReject(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inconsistent indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
|
||
/** | ||
* Wraps a function so it runs inside a webdriver.promise.ControlFlow and | ||
* waits for the flow to complete before continuing. | ||
* @param {!Function} globalFn The function to wrap. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not related to this PR: only one param of the 3 is documented
it('test B', () => { | ||
currentTest = 'B'; | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to test the error handling code paths somehow too.
4b57ea0
to
c67de4a
Compare
@@ -102,4 +102,24 @@ describe('things that should fail', function() { | |||
expect(fakeDriver.getDecimalNumber()).toBeCloseTo(3.1); | |||
expect(fakeDriver.getDecimalNumber()).not.toBeCloseTo(3.14); | |||
}); | |||
|
|||
describe('native promises', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thorn0 this look good for error handling tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks. There is also all this code for dealing with stack traces though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want me to double check that the stack trace is correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind. That code appeared to me more complicated than it actually is. Let's merge this. 👍
err.stack = ''; | ||
} | ||
err.stack = err.stack + '\nFrom asynchronous test: \n' + driverError.stack; | ||
callWhenIdle(flow, done.fail.bind(done, err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to call flow.reset()
here instead of waiting for idle
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we want to reset? If there are pending webdriver tasks we probably want to wait on them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we know that the test has already failed and we can cancel those tasks, why execute them? But I'm not sure. Let's leave it as it is.
* @param {!Function} globalFn The function to wrap. | ||
* @parm {!string} fnName The name of the function being wrapped (e.g. `'it'`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parm -> param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Nit: address spelling.
- Nit: should end comment with a period.
err = new Error('Unknown Error'); | ||
err.stack = ''; | ||
} | ||
err.stack = err.stack + '\nFrom asynchronous test: \n' + driverError.stack; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add fnName
and description
to this information for it to be a bit easier to identify errors?
err.stack += '\nFrom asynchronous test ' + fnName + description + ': \n' + driverError.stack;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jasmine adds that information automatically when we call done.fail
@cnishina you wanna review this? |
* Wraps a function so it runs inside a webdriver.promise.ControlFlow and | ||
* waits for the flow to complete before continuing. | ||
* @param {!webdriver.promise.ControlFlow} flow The WebDriver control flow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: should end comment with a period.
* @param {!Function} globalFn The function to wrap. | ||
* @parm {!string} fnName The name of the function being wrapped (e.g. `'it'`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Nit: address spelling.
- Nit: should end comment with a period.
See angular#68 for details
@cnishina all comments addressed. Can I have an LGTM? 😄 |
See #68 for details