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

allow asynchronous callbacks for jasmine tests #728

Closed
wants to merge 3 commits into from

Conversation

hankduan
Copy link
Contributor

No description provided.

@juliemr
Copy link
Member

juliemr commented Apr 19, 2014

Automated CLA checker says: please sign CLA at http://code.google.com/legal/individual-cla-v1.0.html Please make sure that the email associated with your PR is the same as the email you use to sign.

@hankduan hankduan added cla: no and removed cla: yes labels Apr 19, 2014
@hankduan hankduan added cla: no and removed cla: yes labels Apr 21, 2014
@hankduan hankduan modified the milestones: 0.22.0, 0.21.0 Apr 21, 2014
@juliemr
Copy link
Member

juliemr commented Apr 21, 2014

CLA signature found, thank you!

@hankduan hankduan added cla: yes and removed cla: no labels Apr 21, 2014
@@ -39,12 +39,19 @@ function wrapInControlFlow(globalFn, fnName) {

function asyncTestFn(fn) {
return function(done) {
//deferred object for signaling completion of asychronous function within globalFn
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: space between // and the first letter of the comment

@juliemr
Copy link
Member

juliemr commented Apr 21, 2014

Looks good except for the possible error added to the done callback. Can you add handling for that?

var asyncFnDone = webdriver.promise.defer();

if (fn.length == 0) {
//function with globalFn not asychronous
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space after // here as well

@juliemr
Copy link
Member

juliemr commented Apr 22, 2014

Error handling isn't working - added a comment.

// deferred object for signaling completion of asychronous function within globalFn
var asyncFnDone = webdriver.promise.defer();

if (fn.length == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this asyncTestFunction always called with just a single non-array (Function) parameter which probably doesn't have a length property which then would cause a non-strict comparison of undefined and 0?

Not sure if you are trying to check if the function is defined to take a done callback as a parameter, which I think you will have to do some function source pattern matching to check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length Ok so it seems length returns number of parameter for a function. Didn't know that.

@hankduan hankduan closed this in 43ff9e5 Apr 25, 2014
@davemo
Copy link
Contributor

davemo commented May 5, 2014

I just ran into this trying to use jasmine-given (which utilizes async done callbacks); was this ever merged into master?

@davemo
Copy link
Contributor

davemo commented May 5, 2014

Hmm I see that it was, just trying to resolve if a release has been pushed to NPM with this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants