Skip to content
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

Rule Proposal: Recommend to pass promises to expect() directly if possible #32

Open
alecxe opened this issue Jul 10, 2016 · 0 comments
Open
Assignees
Milestone

Comments

@alecxe
Copy link
Owner

alecxe commented Jul 10, 2016

There is a common anti-pattern in Protractor when something is explicitly resolved and then asserted instead of passing a promise directly to expect() which is patched to understand promises and resolve them implicitly before making an expectation.

This should issue a warning:

element(by.css("#myid")).getText().then(function (text) {
    expect(text).toEqual("My Text");
});

This should be used instead:

expect(element(by.css("#myid")).getText()).toEqual("My Text");

I can imagine that this would not of course catch all the violations of the type, but I think, at the very least, the rule should look that the promise resolution functions argument (text in this case) is not then passed to expect()..

@alecxe alecxe changed the title Recommend to pass promises to expect() directly if possible Rule Proposal: Recommend to pass promises to expect() directly if possible Jul 10, 2016
@alecxe alecxe added this to the 1.0 milestone Jun 30, 2017
@alecxe alecxe modified the milestones: 1.0, 2.0 Jul 27, 2019
@alecxe alecxe self-assigned this Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant