Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

chore(promises): Wait for promises explicitly - #70

Merged
cnishina merged 1 commit into
angular:jasminewd2from
sjelin:promise
Dec 6, 2016
Merged

chore(promises): Wait for promises explicitly#70
cnishina merged 1 commit into
angular:jasminewd2from
sjelin:promise

Conversation

@sjelin

Copy link
Copy Markdown
Contributor

See #68 for details

@sjelin
sjelinforce-pushed the promise branch 3 times, most recently from d45aa6e to 4ab4f2fCompareNovember 23, 2016 02:37

@thorn0thorn0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks great overall 👍

Comment threadindex.js
}
}
}, flow);
}, 'Run ' + fnName + description + ' in control flow').then(seal(done), function(err) {

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threadindex.js

flow.execute(function controlFlowExecute() {
return new webdriver.promise.Promise(function(fulfill, reject) {
function wrappedReject(err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: inconsistent indentation

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed

Comment threadindex.js

/**
* Wraps a function so it runs inside a webdriver.promise.ControlFlow and
* waits for the flow to complete before continuing.

Copy link
Copy Markdown
Contributor

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

Comment threadspec/adapterSpec.js
it('test B', () => {
currentTest = 'B';
});
});

Copy link
Copy Markdown
Contributor

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.

@sjelin
sjelinforce-pushed the promise branch 3 times, most recently from 4b57ea0 to c67de4aCompareNovember 23, 2016 20:16
Comment threadspec/errorSpec.js
expect(fakeDriver.getDecimalNumber()).not.toBeCloseTo(3.14);
});

describe('native promises', function() {

Copy link
Copy Markdown
ContributorAuthor

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?

Copy link
Copy Markdown
Contributor

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...

Copy link
Copy Markdown
ContributorAuthor

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?

Copy link
Copy Markdown
Contributor

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. 👍

Comment threadindex.js
err = new Error('Unknown Error');
err.stack = '';
}
err.stack = err.stack + '\nFrom asynchronous test: \n' + driverError.stack;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
ContributorAuthor

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

Copy link
Copy Markdown
Contributor

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.

Comment threadindex.js
* 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
* @param {!Function} globalFn The function to wrap.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

parm -> param

Copy link
Copy Markdown
Contributor

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.

Comment threadindex.js
if (!err) {
err = new Error('Unknown Error');
err.stack = '';
}

Copy link
Copy Markdown
Contributor

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;

Copy link
Copy Markdown
ContributorAuthor

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

@sjelin

Copy link
Copy Markdown
ContributorAuthor

@cnishina you wanna review this?

@cnishinacnishina self-assigned this Dec 5, 2016
Comment threadindex.js

/**
* Wraps a function so it runs inside a webdriver.promise.ControlFlow and
* waits for the flow to complete before continuing.

Copy link
Copy Markdown
Contributor

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.

Comment threadindex.js
* 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
* @param {!Function} globalFn The function to wrap.

Copy link
Copy Markdown
Contributor

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.

@sjelin

Copy link
Copy Markdown
ContributorAuthor

@cnishina all comments addressed. Can I have an LGTM? 😄

@cnishina
cnishina merged commit 47863c4 into angular:jasminewd2Dec 6, 2016
cnishina pushed a commit to cnishina/jasminewd that referenced this pull request Jan 6, 2017
cnishina pushed a commit that referenced this pull request Jan 6, 2017
Sign up for freeto 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.

3 participants

@sjelin@thorn0@cnishina